From 54f843c6aa7cebf97ffd1b2f70df9ae128fef252 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Thu, 8 Jun 2023 08:28:55 -0700 Subject: [PATCH 1/3] armcontainerregistry 1.1.0-beta.2 release --- .../armcontainerregistry/CHANGELOG.md | 6 + .../armcontainerregistry/README.md | 33 + .../armcontainerregistry/agentpools_client.go | 96 +- .../armcontainerregistry/autorest.md | 8 +- .../armcontainerregistry/build.go | 2 +- .../armcontainerregistry/cacherules_client.go | 81 +- .../armcontainerregistry/client_factory.go | 3 +- .../connectedregistries_client.go | 98 +- .../armcontainerregistry/constants.go | 13 +- .../credentialsets_client.go | 81 +- .../exportpipelines_client.go | 59 +- .../fake/agentpools_server.go | 288 +++ .../fake/cacherules_server.go | 257 +++ .../fake/connectedregistries_server.go | 305 ++++ .../fake/credentialsets_server.go | 257 +++ .../fake/exportpipelines_server.go | 213 +++ .../fake/importpipelines_server.go | 213 +++ .../armcontainerregistry/fake/internal.go | 78 + .../fake/operations_server.go | 90 + .../fake/pipelineruns_server.go | 213 +++ .../fake/polymorphic_helpers.go | 91 + .../fake/privateendpointconnections_server.go | 213 +++ .../fake/registries_server.go | 661 +++++++ .../fake/replications_server.go | 257 +++ .../armcontainerregistry/fake/runs_server.go | 264 +++ .../fake/scopemaps_server.go | 257 +++ .../fake/taskruns_server.go | 288 +++ .../armcontainerregistry/fake/tasks_server.go | 288 +++ .../armcontainerregistry/fake/time_rfc3339.go | 86 + .../fake/tokens_server.go | 257 +++ .../fake/webhooks_server.go | 356 ++++ .../armcontainerregistry/go.mod | 10 +- .../armcontainerregistry/go.sum | 20 +- .../importpipelines_client.go | 59 +- .../armcontainerregistry/models.go | 1545 ++++++++--------- .../armcontainerregistry/models_serde.go | 3 +- .../armcontainerregistry/operations_client.go | 5 +- .../pipelineruns_client.go | 59 +- .../polymorphic_helpers.go | 18 +- .../privateendpointconnections_client.go | 59 +- .../armcontainerregistry/registries_client.go | 251 ++- .../replications_client.go | 81 +- .../armcontainerregistry/response_types.go | 3 +- .../armcontainerregistry/runs_client.go | 74 +- .../armcontainerregistry/scopemaps_client.go | 81 +- .../armcontainerregistry/taskruns_client.go | 96 +- .../armcontainerregistry/tasks_client.go | 96 +- .../armcontainerregistry/time_rfc3339.go | 3 +- .../armcontainerregistry/tokens_client.go | 81 +- .../armcontainerregistry/webhooks_client.go | 113 +- 50 files changed, 6844 insertions(+), 1225 deletions(-) create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/internal.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/polymorphic_helpers.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md b/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md index 1eeacf95a9a9..d2d1c2e14e35 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0-beta.2 (2023-06-08) + +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + ## 1.1.0-beta.1 (2023-03-27) ### Features Added diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/README.md b/sdk/resourcemanager/containerregistry/armcontainerregistry/README.md index 007e96b125f7..8a6ddd0116a9 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/README.md +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/README.md @@ -138,6 +138,39 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewImportPipelinesClient() ``` +## Fakes + +The `fake` package provides implementations for fake servers that can be used for testing. + +To create a fake server, declare an instance of the required fake server type(s). + +```go +myFakeAgentPoolsServer := fake.AgentPoolsServer{} +``` + +Next, provide func implementations for the methods you wish to fake. +The named return variables can be used to simplify return value construction. + +```go +myFakeAgentPoolsServer.Get = func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistry.AgentPoolsClientGetOptions) (resp azfake.Responder[armcontainerregistry.AgentPoolsClientGetResponse], errResp azfake.ErrorResponder) { + // TODO: resp.SetResponse(/* your fake AgentPoolsClientGetResponse response */) + return +} +``` + +You connect the fake server to a client instance during construction through the optional transport. + +Use `NewTokenCredential()` from `azcore/fake` to obtain a fake credential. + +```go +import azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" +client, err := armcontainerregistry.NewAgentPoolsClient("subscriptionID", azfake.NewTokenCredential(), &arm.ClientOptions{ + ClientOptions: azcore.ClientOptions{ + Transport: fake.NewAgentPoolsServerTransport(&myFakeAgentPoolsServer), + }, +}) +``` + ## More sample code - [Container Registry](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/containerregistry/registry) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/agentpools_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/agentpools_client.go index 22b79a3fbcd3..ecef97ced047 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/agentpools_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/agentpools_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 armcontainerregistry @@ -59,7 +58,8 @@ func (client *AgentPoolsClient) BeginCreate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller[AgentPoolsClientCreateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[AgentPoolsClientCreateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[AgentPoolsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -70,18 +70,24 @@ func (client *AgentPoolsClient) BeginCreate(ctx context.Context, resourceGroupNa // // Generated from API version 2019-06-01-preview func (client *AgentPoolsClient) create(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.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, registryName, agentPoolName, agentPool, 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 +114,10 @@ func (client *AgentPoolsClient) createCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, agentPool) + if err := runtime.MarshalAsJSON(req, agentPool); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a specified agent pool resource. @@ -125,7 +134,8 @@ func (client *AgentPoolsClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller[AgentPoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[AgentPoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[AgentPoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -136,18 +146,24 @@ func (client *AgentPoolsClient) BeginDelete(ctx context.Context, resourceGroupNa // // Generated from API version 2019-06-01-preview func (client *AgentPoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.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, registryName, agentPoolName, 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 +202,25 @@ func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourc // - agentPoolName - The name of the agent pool. // - options - AgentPoolsClientGetOptions contains the optional parameters for the AgentPoolsClient.Get method. func (client *AgentPoolsClient) Get(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientGetOptions) (AgentPoolsClientGetResponse, error) { + var err error + const operationName = "AgentPoolsClient.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, registryName, agentPoolName, options) if err != nil { return AgentPoolsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AgentPoolsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AgentPoolsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AgentPoolsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -246,18 +269,25 @@ func (client *AgentPoolsClient) getHandleResponse(resp *http.Response) (AgentPoo // - options - AgentPoolsClientGetQueueStatusOptions contains the optional parameters for the AgentPoolsClient.GetQueueStatus // method. func (client *AgentPoolsClient) GetQueueStatus(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientGetQueueStatusOptions) (AgentPoolsClientGetQueueStatusResponse, error) { + var err error + const operationName = "AgentPoolsClient.GetQueueStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getQueueStatusCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) if err != nil { return AgentPoolsClientGetQueueStatusResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AgentPoolsClientGetQueueStatusResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AgentPoolsClientGetQueueStatusResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AgentPoolsClientGetQueueStatusResponse{}, err } - return client.getQueueStatusHandleResponse(resp) + resp, err := client.getQueueStatusHandleResponse(httpResp) + return resp, err } // getQueueStatusCreateRequest creates the GetQueueStatus request. @@ -308,6 +338,7 @@ func (client *AgentPoolsClient) NewListPager(resourceGroupName string, registryN return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *AgentPoolsClientListResponse) (AgentPoolsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AgentPoolsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -327,6 +358,7 @@ func (client *AgentPoolsClient) NewListPager(resourceGroupName string, registryN } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -377,7 +409,8 @@ func (client *AgentPoolsClient) BeginUpdate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller[AgentPoolsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[AgentPoolsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[AgentPoolsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -388,18 +421,24 @@ func (client *AgentPoolsClient) BeginUpdate(ctx context.Context, resourceGroupNa // // Generated from API version 2019-06-01-preview func (client *AgentPoolsClient) update(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.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, registryName, agentPoolName, updateParameters, 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 } // updateCreateRequest creates the Update request. @@ -426,5 +465,8 @@ func (client *AgentPoolsClient) updateCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, updateParameters) + if err := runtime.MarshalAsJSON(req, updateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md b/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md index 8f072ae69bc8..e96465bf3d69 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md @@ -8,6 +8,8 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/containerregistry/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/containerregistry/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0-beta.1 - -``` \ No newline at end of file +module-version: 1.1.0-beta.2 +azcore-version: 1.7.0-beta.2 +generate-fakes: true +inject-spans: true +``` diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go index c28d65e715a5..9d35ebe68300 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go @@ -2,6 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/containerregistry/armcontainerregistry +//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.50" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/containerregistry/armcontainerregistry package armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/cacherules_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/cacherules_client.go index b9acaa2dc192..2878954f63a2 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/cacherules_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/cacherules_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 armcontainerregistry @@ -59,9 +58,10 @@ func (client *CacheRulesClient) BeginCreate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CacheRulesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -72,18 +72,24 @@ func (client *CacheRulesClient) BeginCreate(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *CacheRulesClient) create(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, cacheRuleCreateParameters CacheRule, options *CacheRulesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "CacheRulesClient.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, registryName, cacheRuleName, cacheRuleCreateParameters, 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. @@ -110,7 +116,10 @@ func (client *CacheRulesClient) createCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, cacheRuleCreateParameters) + if err := runtime.MarshalAsJSON(req, cacheRuleCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a cache rule resource from a container registry. @@ -127,9 +136,10 @@ func (client *CacheRulesClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CacheRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -140,18 +150,24 @@ func (client *CacheRulesClient) BeginDelete(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *CacheRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, options *CacheRulesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CacheRulesClient.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, registryName, cacheRuleName, 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. @@ -190,18 +206,25 @@ func (client *CacheRulesClient) deleteCreateRequest(ctx context.Context, resourc // - cacheRuleName - The name of the cache rule. // - options - CacheRulesClientGetOptions contains the optional parameters for the CacheRulesClient.Get method. func (client *CacheRulesClient) Get(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, options *CacheRulesClientGetOptions) (CacheRulesClientGetResponse, error) { + var err error + const operationName = "CacheRulesClient.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, registryName, cacheRuleName, options) if err != nil { return CacheRulesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return CacheRulesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return CacheRulesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CacheRulesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -252,6 +275,7 @@ func (client *CacheRulesClient) NewListPager(resourceGroupName string, registryN return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *CacheRulesClientListResponse) (CacheRulesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CacheRulesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -271,6 +295,7 @@ func (client *CacheRulesClient) NewListPager(resourceGroupName string, registryN } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -321,9 +346,10 @@ func (client *CacheRulesClient) BeginUpdate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CacheRulesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CacheRulesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -334,18 +360,24 @@ func (client *CacheRulesClient) BeginUpdate(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *CacheRulesClient) update(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, cacheRuleUpdateParameters CacheRuleUpdateParameters, options *CacheRulesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CacheRulesClient.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, registryName, cacheRuleName, cacheRuleUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -372,5 +404,8 @@ func (client *CacheRulesClient) updateCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, cacheRuleUpdateParameters) + if err := runtime.MarshalAsJSON(req, cacheRuleUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/client_factory.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/client_factory.go index e64c6cd0a56e..baaf11117027 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/client_factory.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/connectedregistries_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/connectedregistries_client.go index 924ad34cfcae..dab2285fd747 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/connectedregistries_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/connectedregistries_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *ConnectedRegistriesClient) BeginCreate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ConnectedRegistriesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *ConnectedRegistriesClient) BeginCreate(ctx context.Context, resour // // Generated from API version 2023-01-01-preview func (client *ConnectedRegistriesClient) create(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryCreateParameters ConnectedRegistry, options *ConnectedRegistriesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ConnectedRegistriesClient.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, registryName, connectedRegistryName, connectedRegistryCreateParameters, 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. @@ -111,7 +117,10 @@ func (client *ConnectedRegistriesClient) createCreateRequest(ctx context.Context reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, connectedRegistryCreateParameters) + if err := runtime.MarshalAsJSON(req, connectedRegistryCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDeactivate - Deactivates the connected registry instance. @@ -129,9 +138,10 @@ func (client *ConnectedRegistriesClient) BeginDeactivate(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientDeactivateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientDeactivateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ConnectedRegistriesClientDeactivateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *ConnectedRegistriesClient) BeginDeactivate(ctx context.Context, re // // Generated from API version 2023-01-01-preview func (client *ConnectedRegistriesClient) deactivate(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesClientBeginDeactivateOptions) (*http.Response, error) { + var err error + const operationName = "ConnectedRegistriesClient.BeginDeactivate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deactivateCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, 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 } // deactivateCreateRequest creates the Deactivate request. @@ -198,9 +214,10 @@ func (client *ConnectedRegistriesClient) BeginDelete(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ConnectedRegistriesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -211,18 +228,24 @@ func (client *ConnectedRegistriesClient) BeginDelete(ctx context.Context, resour // // Generated from API version 2023-01-01-preview func (client *ConnectedRegistriesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ConnectedRegistriesClient.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, registryName, connectedRegistryName, 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. @@ -261,18 +284,25 @@ func (client *ConnectedRegistriesClient) deleteCreateRequest(ctx context.Context // - connectedRegistryName - The name of the connected registry. // - options - ConnectedRegistriesClientGetOptions contains the optional parameters for the ConnectedRegistriesClient.Get method. func (client *ConnectedRegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesClientGetOptions) (ConnectedRegistriesClientGetResponse, error) { + var err error + const operationName = "ConnectedRegistriesClient.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, registryName, connectedRegistryName, options) if err != nil { return ConnectedRegistriesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ConnectedRegistriesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConnectedRegistriesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ConnectedRegistriesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -324,6 +354,7 @@ func (client *ConnectedRegistriesClient) NewListPager(resourceGroupName string, return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ConnectedRegistriesClientListResponse) (ConnectedRegistriesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectedRegistriesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -343,6 +374,7 @@ func (client *ConnectedRegistriesClient) NewListPager(resourceGroupName string, } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -397,9 +429,10 @@ func (client *ConnectedRegistriesClient) BeginUpdate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectedRegistriesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ConnectedRegistriesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -410,18 +443,24 @@ func (client *ConnectedRegistriesClient) BeginUpdate(ctx context.Context, resour // // Generated from API version 2023-01-01-preview func (client *ConnectedRegistriesClient) update(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryUpdateParameters ConnectedRegistryUpdateParameters, options *ConnectedRegistriesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ConnectedRegistriesClient.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, registryName, connectedRegistryName, connectedRegistryUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -448,5 +487,8 @@ func (client *ConnectedRegistriesClient) updateCreateRequest(ctx context.Context reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, connectedRegistryUpdateParameters) + if err := runtime.MarshalAsJSON(req, connectedRegistryUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/constants.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/constants.go index fcfc2caaf1dc..9fca692a842b 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/constants.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry const ( moduleName = "armcontainerregistry" - moduleVersion = "v1.1.0-beta.1" + moduleVersion = "v1.1.0-beta.2" ) // Action - The action of IP ACL rule. @@ -562,19 +561,19 @@ func PossibleRegistryUsageUnitValues() []RegistryUsageUnit { type ResourceIdentityType string const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" - ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" - ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" ) // PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. func PossibleResourceIdentityTypeValues() []ResourceIdentityType { return []ResourceIdentityType{ + ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, - ResourceIdentityTypeUserAssigned, ResourceIdentityTypeSystemAssignedUserAssigned, - ResourceIdentityTypeNone, + ResourceIdentityTypeUserAssigned, } } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/credentialsets_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/credentialsets_client.go index 44ec95408fe1..daf741dfa898 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/credentialsets_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/credentialsets_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *CredentialSetsClient) BeginCreate(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CredentialSetsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *CredentialSetsClient) BeginCreate(ctx context.Context, resourceGro // // Generated from API version 2023-01-01-preview func (client *CredentialSetsClient) create(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, credentialSetCreateParameters CredentialSet, options *CredentialSetsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "CredentialSetsClient.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, registryName, credentialSetName, credentialSetCreateParameters, 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. @@ -111,7 +117,10 @@ func (client *CredentialSetsClient) createCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, credentialSetCreateParameters) + if err := runtime.MarshalAsJSON(req, credentialSetCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a credential set from a container registry. @@ -129,9 +138,10 @@ func (client *CredentialSetsClient) BeginDelete(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CredentialSetsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *CredentialSetsClient) BeginDelete(ctx context.Context, resourceGro // // Generated from API version 2023-01-01-preview func (client *CredentialSetsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, options *CredentialSetsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CredentialSetsClient.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, registryName, credentialSetName, 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. @@ -192,18 +208,25 @@ func (client *CredentialSetsClient) deleteCreateRequest(ctx context.Context, res // - credentialSetName - The name of the credential set. // - options - CredentialSetsClientGetOptions contains the optional parameters for the CredentialSetsClient.Get method. func (client *CredentialSetsClient) Get(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, options *CredentialSetsClientGetOptions) (CredentialSetsClientGetResponse, error) { + var err error + const operationName = "CredentialSetsClient.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, registryName, credentialSetName, options) if err != nil { return CredentialSetsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return CredentialSetsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return CredentialSetsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CredentialSetsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -254,6 +277,7 @@ func (client *CredentialSetsClient) NewListPager(resourceGroupName string, regis return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *CredentialSetsClientListResponse) (CredentialSetsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CredentialSetsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -273,6 +297,7 @@ func (client *CredentialSetsClient) NewListPager(resourceGroupName string, regis } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -324,9 +349,10 @@ func (client *CredentialSetsClient) BeginUpdate(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CredentialSetsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CredentialSetsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -337,18 +363,24 @@ func (client *CredentialSetsClient) BeginUpdate(ctx context.Context, resourceGro // // Generated from API version 2023-01-01-preview func (client *CredentialSetsClient) update(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, credentialSetUpdateParameters CredentialSetUpdateParameters, options *CredentialSetsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CredentialSetsClient.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, registryName, credentialSetName, credentialSetUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -375,5 +407,8 @@ func (client *CredentialSetsClient) updateCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, credentialSetUpdateParameters) + if err := runtime.MarshalAsJSON(req, credentialSetUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/exportpipelines_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/exportpipelines_client.go index 428d046bd677..782b4446aefb 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/exportpipelines_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/exportpipelines_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *ExportPipelinesClient) BeginCreate(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportPipelinesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportPipelinesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ExportPipelinesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *ExportPipelinesClient) BeginCreate(ctx context.Context, resourceGr // // Generated from API version 2023-01-01-preview func (client *ExportPipelinesClient) create(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline, options *ExportPipelinesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ExportPipelinesClient.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, registryName, exportPipelineName, exportPipelineCreateParameters, 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. @@ -111,7 +117,10 @@ func (client *ExportPipelinesClient) createCreateRequest(ctx context.Context, re reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, exportPipelineCreateParameters) + if err := runtime.MarshalAsJSON(req, exportPipelineCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes an export pipeline from a container registry. @@ -129,9 +138,10 @@ func (client *ExportPipelinesClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportPipelinesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportPipelinesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ExportPipelinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *ExportPipelinesClient) BeginDelete(ctx context.Context, resourceGr // // Generated from API version 2023-01-01-preview func (client *ExportPipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ExportPipelinesClient.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, registryName, exportPipelineName, 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. @@ -192,18 +208,25 @@ func (client *ExportPipelinesClient) deleteCreateRequest(ctx context.Context, re // - exportPipelineName - The name of the export pipeline. // - options - ExportPipelinesClientGetOptions contains the optional parameters for the ExportPipelinesClient.Get method. func (client *ExportPipelinesClient) Get(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesClientGetOptions) (ExportPipelinesClientGetResponse, error) { + var err error + const operationName = "ExportPipelinesClient.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, registryName, exportPipelineName, options) if err != nil { return ExportPipelinesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportPipelinesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportPipelinesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportPipelinesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -255,6 +278,7 @@ func (client *ExportPipelinesClient) NewListPager(resourceGroupName string, regi return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ExportPipelinesClientListResponse) (ExportPipelinesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExportPipelinesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -274,6 +298,7 @@ func (client *ExportPipelinesClient) NewListPager(resourceGroupName string, regi } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go new file mode 100644 index 000000000000..3609092aeea9 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go @@ -0,0 +1,288 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// AgentPoolsServer is a fake server for instances of the armcontainerregistry.AgentPoolsClient type. +type AgentPoolsServer struct { + // BeginCreate is the fake for method AgentPoolsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool armcontainerregistry.AgentPool, options *armcontainerregistry.AgentPoolsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.AgentPoolsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method AgentPoolsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistry.AgentPoolsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.AgentPoolsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AgentPoolsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistry.AgentPoolsClientGetOptions) (resp azfake.Responder[armcontainerregistry.AgentPoolsClientGetResponse], errResp azfake.ErrorResponder) + + // GetQueueStatus is the fake for method AgentPoolsClient.GetQueueStatus + // HTTP status codes to indicate success: http.StatusOK + GetQueueStatus func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistry.AgentPoolsClientGetQueueStatusOptions) (resp azfake.Responder[armcontainerregistry.AgentPoolsClientGetQueueStatusResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method AgentPoolsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.AgentPoolsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.AgentPoolsClientListResponse]) + + // BeginUpdate is the fake for method AgentPoolsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters armcontainerregistry.AgentPoolUpdateParameters, options *armcontainerregistry.AgentPoolsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.AgentPoolsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAgentPoolsServerTransport creates a new instance of AgentPoolsServerTransport with the provided implementation. +// The returned AgentPoolsServerTransport instance is connected to an instance of armcontainerregistry.AgentPoolsClient by way of the +// undefined.Transporter field. +func NewAgentPoolsServerTransport(srv *AgentPoolsServer) *AgentPoolsServerTransport { + return &AgentPoolsServerTransport{srv: srv} +} + +// AgentPoolsServerTransport connects instances of armcontainerregistry.AgentPoolsClient to instances of AgentPoolsServer. +// Don't use this type directly, use NewAgentPoolsServerTransport instead. +type AgentPoolsServerTransport struct { + srv *AgentPoolsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.AgentPoolsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.AgentPoolsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.AgentPoolsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.AgentPoolsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for AgentPoolsServerTransport. +func (a *AgentPoolsServerTransport) 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 "AgentPoolsClient.BeginCreate": + resp, err = a.dispatchBeginCreate(req) + case "AgentPoolsClient.BeginDelete": + resp, err = a.dispatchBeginDelete(req) + case "AgentPoolsClient.Get": + resp, err = a.dispatchGet(req) + case "AgentPoolsClient.GetQueueStatus": + resp, err = a.dispatchGetQueueStatus(req) + case "AgentPoolsClient.NewListPager": + resp, err = a.dispatchNewListPager(req) + case "AgentPoolsClient.BeginUpdate": + resp, err = a.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if a.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.AgentPool](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(a.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginCreate) { + a.beginCreate = nil + } + + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if a.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(a.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginDelete) { + a.beginDelete = nil + } + + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], 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).AgentPool, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchGetQueueStatus(req *http.Request) (*http.Response, error) { + if a.srv.GetQueueStatus == nil { + return nil, &nonRetriableError{errors.New("method GetQueueStatus not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)/listQueueStatus" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.GetQueueStatus(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], 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).AgentPoolQueueStatus, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if a.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + a.newListPager = &resp + server.PagerResponderInjectNextLinks(a.newListPager, req, func(page *armcontainerregistry.AgentPoolsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(a.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(a.newListPager) { + a.newListPager = nil + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if a.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.AgentPoolUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(a.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginUpdate) { + a.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go new file mode 100644 index 000000000000..64b0999a5763 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go @@ -0,0 +1,257 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// CacheRulesServer is a fake server for instances of the armcontainerregistry.CacheRulesClient type. +type CacheRulesServer struct { + // BeginCreate is the fake for method CacheRulesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, cacheRuleCreateParameters armcontainerregistry.CacheRule, options *armcontainerregistry.CacheRulesClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.CacheRulesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CacheRulesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, options *armcontainerregistry.CacheRulesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.CacheRulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CacheRulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, options *armcontainerregistry.CacheRulesClientGetOptions) (resp azfake.Responder[armcontainerregistry.CacheRulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method CacheRulesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.CacheRulesClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.CacheRulesClientListResponse]) + + // BeginUpdate is the fake for method CacheRulesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, cacheRuleName string, cacheRuleUpdateParameters armcontainerregistry.CacheRuleUpdateParameters, options *armcontainerregistry.CacheRulesClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.CacheRulesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCacheRulesServerTransport creates a new instance of CacheRulesServerTransport with the provided implementation. +// The returned CacheRulesServerTransport instance is connected to an instance of armcontainerregistry.CacheRulesClient by way of the +// undefined.Transporter field. +func NewCacheRulesServerTransport(srv *CacheRulesServer) *CacheRulesServerTransport { + return &CacheRulesServerTransport{srv: srv} +} + +// CacheRulesServerTransport connects instances of armcontainerregistry.CacheRulesClient to instances of CacheRulesServer. +// Don't use this type directly, use NewCacheRulesServerTransport instead. +type CacheRulesServerTransport struct { + srv *CacheRulesServer + beginCreate *azfake.PollerResponder[armcontainerregistry.CacheRulesClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.CacheRulesClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.CacheRulesClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.CacheRulesClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for CacheRulesServerTransport. +func (c *CacheRulesServerTransport) 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 "CacheRulesClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + case "CacheRulesClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "CacheRulesClient.Get": + resp, err = c.dispatchGet(req) + case "CacheRulesClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "CacheRulesClient.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 *CacheRulesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if c.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.CacheRule](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(c.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginCreate) { + c.beginCreate = nil + } + + return resp, nil +} + +func (c *CacheRulesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if c.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(c.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginDelete) { + c.beginDelete = nil + } + + return resp, nil +} + +func (c *CacheRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], 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).CacheRule, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CacheRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if c.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + c.newListPager = &resp + server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.CacheRulesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(c.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(c.newListPager) { + c.newListPager = nil + } + return resp, nil +} + +func (c *CacheRulesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if c.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.CacheRuleUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(c.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginUpdate) { + c.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go new file mode 100644 index 000000000000..a2db9f348cf3 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go @@ -0,0 +1,305 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// ConnectedRegistriesServer is a fake server for instances of the armcontainerregistry.ConnectedRegistriesClient type. +type ConnectedRegistriesServer struct { + // BeginCreate is the fake for method ConnectedRegistriesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryCreateParameters armcontainerregistry.ConnectedRegistry, options *armcontainerregistry.ConnectedRegistriesClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDeactivate is the fake for method ConnectedRegistriesClient.BeginDeactivate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDeactivate func(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *armcontainerregistry.ConnectedRegistriesClientBeginDeactivateOptions) (resp azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientDeactivateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ConnectedRegistriesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *armcontainerregistry.ConnectedRegistriesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ConnectedRegistriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *armcontainerregistry.ConnectedRegistriesClientGetOptions) (resp azfake.Responder[armcontainerregistry.ConnectedRegistriesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ConnectedRegistriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.ConnectedRegistriesClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.ConnectedRegistriesClientListResponse]) + + // BeginUpdate is the fake for method ConnectedRegistriesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryUpdateParameters armcontainerregistry.ConnectedRegistryUpdateParameters, options *armcontainerregistry.ConnectedRegistriesClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewConnectedRegistriesServerTransport creates a new instance of ConnectedRegistriesServerTransport with the provided implementation. +// The returned ConnectedRegistriesServerTransport instance is connected to an instance of armcontainerregistry.ConnectedRegistriesClient by way of the +// undefined.Transporter field. +func NewConnectedRegistriesServerTransport(srv *ConnectedRegistriesServer) *ConnectedRegistriesServerTransport { + return &ConnectedRegistriesServerTransport{srv: srv} +} + +// ConnectedRegistriesServerTransport connects instances of armcontainerregistry.ConnectedRegistriesClient to instances of ConnectedRegistriesServer. +// Don't use this type directly, use NewConnectedRegistriesServerTransport instead. +type ConnectedRegistriesServerTransport struct { + srv *ConnectedRegistriesServer + beginCreate *azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientCreateResponse] + beginDeactivate *azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientDeactivateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.ConnectedRegistriesClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.ConnectedRegistriesClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for ConnectedRegistriesServerTransport. +func (c *ConnectedRegistriesServerTransport) 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 "ConnectedRegistriesClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + case "ConnectedRegistriesClient.BeginDeactivate": + resp, err = c.dispatchBeginDeactivate(req) + case "ConnectedRegistriesClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "ConnectedRegistriesClient.Get": + resp, err = c.dispatchGet(req) + case "ConnectedRegistriesClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "ConnectedRegistriesClient.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 *ConnectedRegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if c.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ConnectedRegistry](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(c.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginCreate) { + c.beginCreate = nil + } + + return resp, nil +} + +func (c *ConnectedRegistriesServerTransport) dispatchBeginDeactivate(req *http.Request) (*http.Response, error) { + if c.srv.BeginDeactivate == nil { + return nil, &nonRetriableError{errors.New("method BeginDeactivate not implemented")} + } + if c.beginDeactivate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)/deactivate" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.BeginDeactivate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginDeactivate = &respr + } + + resp, err := server.PollerResponderNext(c.beginDeactivate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginDeactivate) { + c.beginDeactivate = nil + } + + return resp, nil +} + +func (c *ConnectedRegistriesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if c.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(c.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginDelete) { + c.beginDelete = nil + } + + return resp, nil +} + +func (c *ConnectedRegistriesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], 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).ConnectedRegistry, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectedRegistriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if c.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + filterParam := getOptional(qp.Get("$filter")) + var options *armcontainerregistry.ConnectedRegistriesClientListOptions + if filterParam != nil { + options = &armcontainerregistry.ConnectedRegistriesClientListOptions{ + Filter: filterParam, + } + } + resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], options) + c.newListPager = &resp + server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.ConnectedRegistriesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(c.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(c.newListPager) { + c.newListPager = nil + } + return resp, nil +} + +func (c *ConnectedRegistriesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if c.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ConnectedRegistryUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(c.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginUpdate) { + c.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go new file mode 100644 index 000000000000..2ca1797b208a --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go @@ -0,0 +1,257 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// CredentialSetsServer is a fake server for instances of the armcontainerregistry.CredentialSetsClient type. +type CredentialSetsServer struct { + // BeginCreate is the fake for method CredentialSetsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, credentialSetCreateParameters armcontainerregistry.CredentialSet, options *armcontainerregistry.CredentialSetsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.CredentialSetsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CredentialSetsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, options *armcontainerregistry.CredentialSetsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.CredentialSetsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CredentialSetsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, options *armcontainerregistry.CredentialSetsClientGetOptions) (resp azfake.Responder[armcontainerregistry.CredentialSetsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method CredentialSetsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.CredentialSetsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.CredentialSetsClientListResponse]) + + // BeginUpdate is the fake for method CredentialSetsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, credentialSetName string, credentialSetUpdateParameters armcontainerregistry.CredentialSetUpdateParameters, options *armcontainerregistry.CredentialSetsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.CredentialSetsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCredentialSetsServerTransport creates a new instance of CredentialSetsServerTransport with the provided implementation. +// The returned CredentialSetsServerTransport instance is connected to an instance of armcontainerregistry.CredentialSetsClient by way of the +// undefined.Transporter field. +func NewCredentialSetsServerTransport(srv *CredentialSetsServer) *CredentialSetsServerTransport { + return &CredentialSetsServerTransport{srv: srv} +} + +// CredentialSetsServerTransport connects instances of armcontainerregistry.CredentialSetsClient to instances of CredentialSetsServer. +// Don't use this type directly, use NewCredentialSetsServerTransport instead. +type CredentialSetsServerTransport struct { + srv *CredentialSetsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.CredentialSetsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.CredentialSetsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.CredentialSetsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.CredentialSetsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for CredentialSetsServerTransport. +func (c *CredentialSetsServerTransport) 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 "CredentialSetsClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + case "CredentialSetsClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "CredentialSetsClient.Get": + resp, err = c.dispatchGet(req) + case "CredentialSetsClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "CredentialSetsClient.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 *CredentialSetsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if c.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.CredentialSet](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(c.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginCreate) { + c.beginCreate = nil + } + + return resp, nil +} + +func (c *CredentialSetsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if c.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(c.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginDelete) { + c.beginDelete = nil + } + + return resp, nil +} + +func (c *CredentialSetsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], 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).CredentialSet, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CredentialSetsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if c.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + c.newListPager = &resp + server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.CredentialSetsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(c.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(c.newListPager) { + c.newListPager = nil + } + return resp, nil +} + +func (c *CredentialSetsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if c.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.CredentialSetUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + c.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(c.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(c.beginUpdate) { + c.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go new file mode 100644 index 000000000000..8d59f2f23578 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go @@ -0,0 +1,213 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// ExportPipelinesServer is a fake server for instances of the armcontainerregistry.ExportPipelinesClient type. +type ExportPipelinesServer struct { + // BeginCreate is the fake for method ExportPipelinesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters armcontainerregistry.ExportPipeline, options *armcontainerregistry.ExportPipelinesClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.ExportPipelinesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ExportPipelinesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *armcontainerregistry.ExportPipelinesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.ExportPipelinesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ExportPipelinesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *armcontainerregistry.ExportPipelinesClientGetOptions) (resp azfake.Responder[armcontainerregistry.ExportPipelinesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ExportPipelinesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.ExportPipelinesClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.ExportPipelinesClientListResponse]) +} + +// NewExportPipelinesServerTransport creates a new instance of ExportPipelinesServerTransport with the provided implementation. +// The returned ExportPipelinesServerTransport instance is connected to an instance of armcontainerregistry.ExportPipelinesClient by way of the +// undefined.Transporter field. +func NewExportPipelinesServerTransport(srv *ExportPipelinesServer) *ExportPipelinesServerTransport { + return &ExportPipelinesServerTransport{srv: srv} +} + +// ExportPipelinesServerTransport connects instances of armcontainerregistry.ExportPipelinesClient to instances of ExportPipelinesServer. +// Don't use this type directly, use NewExportPipelinesServerTransport instead. +type ExportPipelinesServerTransport struct { + srv *ExportPipelinesServer + beginCreate *azfake.PollerResponder[armcontainerregistry.ExportPipelinesClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.ExportPipelinesClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.ExportPipelinesClientListResponse] +} + +// Do implements the policy.Transporter interface for ExportPipelinesServerTransport. +func (e *ExportPipelinesServerTransport) 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 "ExportPipelinesClient.BeginCreate": + resp, err = e.dispatchBeginCreate(req) + case "ExportPipelinesClient.BeginDelete": + resp, err = e.dispatchBeginDelete(req) + case "ExportPipelinesClient.Get": + resp, err = e.dispatchGet(req) + case "ExportPipelinesClient.NewListPager": + resp, err = e.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if e.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ExportPipeline](req) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + e.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(e.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(e.beginCreate) { + e.beginCreate = nil + } + + return resp, nil +} + +func (e *ExportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if e.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := e.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + e.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(e.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(e.beginDelete) { + e.beginDelete = nil + } + + return resp, nil +} + +func (e *ExportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := e.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], 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).ExportPipeline, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *ExportPipelinesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if e.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := e.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + e.newListPager = &resp + server.PagerResponderInjectNextLinks(e.newListPager, req, func(page *armcontainerregistry.ExportPipelinesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(e.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(e.newListPager) { + e.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go new file mode 100644 index 000000000000..52f6784b8f4a --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go @@ -0,0 +1,213 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// ImportPipelinesServer is a fake server for instances of the armcontainerregistry.ImportPipelinesClient type. +type ImportPipelinesServer struct { + // BeginCreate is the fake for method ImportPipelinesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, importPipelineCreateParameters armcontainerregistry.ImportPipeline, options *armcontainerregistry.ImportPipelinesClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.ImportPipelinesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ImportPipelinesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *armcontainerregistry.ImportPipelinesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.ImportPipelinesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ImportPipelinesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *armcontainerregistry.ImportPipelinesClientGetOptions) (resp azfake.Responder[armcontainerregistry.ImportPipelinesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ImportPipelinesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.ImportPipelinesClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.ImportPipelinesClientListResponse]) +} + +// NewImportPipelinesServerTransport creates a new instance of ImportPipelinesServerTransport with the provided implementation. +// The returned ImportPipelinesServerTransport instance is connected to an instance of armcontainerregistry.ImportPipelinesClient by way of the +// undefined.Transporter field. +func NewImportPipelinesServerTransport(srv *ImportPipelinesServer) *ImportPipelinesServerTransport { + return &ImportPipelinesServerTransport{srv: srv} +} + +// ImportPipelinesServerTransport connects instances of armcontainerregistry.ImportPipelinesClient to instances of ImportPipelinesServer. +// Don't use this type directly, use NewImportPipelinesServerTransport instead. +type ImportPipelinesServerTransport struct { + srv *ImportPipelinesServer + beginCreate *azfake.PollerResponder[armcontainerregistry.ImportPipelinesClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.ImportPipelinesClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.ImportPipelinesClientListResponse] +} + +// Do implements the policy.Transporter interface for ImportPipelinesServerTransport. +func (i *ImportPipelinesServerTransport) 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 "ImportPipelinesClient.BeginCreate": + resp, err = i.dispatchBeginCreate(req) + case "ImportPipelinesClient.BeginDelete": + resp, err = i.dispatchBeginDelete(req) + case "ImportPipelinesClient.Get": + resp, err = i.dispatchGet(req) + case "ImportPipelinesClient.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 *ImportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if i.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if i.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ImportPipeline](req) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + i.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(i.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(i.beginCreate) { + i.beginCreate = nil + } + + return resp, nil +} + +func (i *ImportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if i.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if i.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := i.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + i.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(i.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(i.beginDelete) { + i.beginDelete = nil + } + + return resp, nil +} + +func (i *ImportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := i.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], 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).ImportPipeline, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *ImportPipelinesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if i.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := i.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + i.newListPager = &resp + server.PagerResponderInjectNextLinks(i.newListPager, req, func(page *armcontainerregistry.ImportPipelinesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(i.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(i.newListPager) { + i.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/internal.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/internal.go new file mode 100644 index 000000000000..e9c8222f2199 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/internal.go @@ -0,0 +1,78 @@ +//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 ( + "io" + "net/http" + "reflect" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func getHeaderValue(h http.Header, k string) string { + v := h[k] + if len(v) == 0 { + return "" + } + return v[0] +} + +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 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 contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go new file mode 100644 index 000000000000..712dade6206b --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go @@ -0,0 +1,90 @@ +//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/containerregistry/armcontainerregistry" + "net/http" +) + +// OperationsServer is a fake server for instances of the armcontainerregistry.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcontainerregistry.OperationsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armcontainerregistry.OperationsClient by way of the +// undefined.Transporter field. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{srv: srv} +} + +// OperationsServerTransport connects instances of armcontainerregistry.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *azfake.PagerResponder[armcontainerregistry.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("method NewListPager not implemented")} + } + if o.newListPager == nil { + resp := o.srv.NewListPager(nil) + o.newListPager = &resp + server.PagerResponderInjectNextLinks(o.newListPager, req, func(page *armcontainerregistry.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(o.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(o.newListPager) { + o.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go new file mode 100644 index 000000000000..f0c03ef0720a --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go @@ -0,0 +1,213 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// PipelineRunsServer is a fake server for instances of the armcontainerregistry.PipelineRunsClient type. +type PipelineRunsServer struct { + // BeginCreate is the fake for method PipelineRunsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, pipelineRunCreateParameters armcontainerregistry.PipelineRun, options *armcontainerregistry.PipelineRunsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.PipelineRunsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PipelineRunsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *armcontainerregistry.PipelineRunsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.PipelineRunsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PipelineRunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *armcontainerregistry.PipelineRunsClientGetOptions) (resp azfake.Responder[armcontainerregistry.PipelineRunsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PipelineRunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.PipelineRunsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.PipelineRunsClientListResponse]) +} + +// NewPipelineRunsServerTransport creates a new instance of PipelineRunsServerTransport with the provided implementation. +// The returned PipelineRunsServerTransport instance is connected to an instance of armcontainerregistry.PipelineRunsClient by way of the +// undefined.Transporter field. +func NewPipelineRunsServerTransport(srv *PipelineRunsServer) *PipelineRunsServerTransport { + return &PipelineRunsServerTransport{srv: srv} +} + +// PipelineRunsServerTransport connects instances of armcontainerregistry.PipelineRunsClient to instances of PipelineRunsServer. +// Don't use this type directly, use NewPipelineRunsServerTransport instead. +type PipelineRunsServerTransport struct { + srv *PipelineRunsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.PipelineRunsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.PipelineRunsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.PipelineRunsClientListResponse] +} + +// Do implements the policy.Transporter interface for PipelineRunsServerTransport. +func (p *PipelineRunsServerTransport) 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 "PipelineRunsClient.BeginCreate": + resp, err = p.dispatchBeginCreate(req) + case "PipelineRunsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PipelineRunsClient.Get": + resp, err = p.dispatchGet(req) + case "PipelineRunsClient.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 *PipelineRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if p.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.PipelineRun](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + p.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(p.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(p.beginCreate) { + p.beginCreate = nil + } + + return resp, nil +} + +func (p *PipelineRunsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if p.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + p.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(p.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(p.beginDelete) { + p.beginDelete = nil + } + + return resp, nil +} + +func (p *PipelineRunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], 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).PipelineRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PipelineRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if p.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + p.newListPager = &resp + server.PagerResponderInjectNextLinks(p.newListPager, req, func(page *armcontainerregistry.PipelineRunsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(p.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(p.newListPager) { + p.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/polymorphic_helpers.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..73d14565ff9d --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/polymorphic_helpers.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 ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" +) + +func unmarshalRunRequestClassification(rawMsg json.RawMessage) (armcontainerregistry.RunRequestClassification, 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 armcontainerregistry.RunRequestClassification + switch m["type"] { + case "DockerBuildRequest": + b = &armcontainerregistry.DockerBuildRequest{} + case "EncodedTaskRunRequest": + b = &armcontainerregistry.EncodedTaskRunRequest{} + case "FileTaskRunRequest": + b = &armcontainerregistry.FileTaskRunRequest{} + case "TaskRunRequest": + b = &armcontainerregistry.TaskRunRequest{} + default: + b = &armcontainerregistry.RunRequest{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalTaskStepPropertiesClassification(rawMsg json.RawMessage) (armcontainerregistry.TaskStepPropertiesClassification, 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 armcontainerregistry.TaskStepPropertiesClassification + switch m["type"] { + case string(armcontainerregistry.StepTypeDocker): + b = &armcontainerregistry.DockerBuildStep{} + case string(armcontainerregistry.StepTypeEncodedTask): + b = &armcontainerregistry.EncodedTaskStep{} + case string(armcontainerregistry.StepTypeFileTask): + b = &armcontainerregistry.FileTaskStep{} + default: + b = &armcontainerregistry.TaskStepProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalTaskStepUpdateParametersClassification(rawMsg json.RawMessage) (armcontainerregistry.TaskStepUpdateParametersClassification, 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 armcontainerregistry.TaskStepUpdateParametersClassification + switch m["type"] { + case string(armcontainerregistry.StepTypeDocker): + b = &armcontainerregistry.DockerBuildStepUpdateParameters{} + case string(armcontainerregistry.StepTypeEncodedTask): + b = &armcontainerregistry.EncodedTaskStepUpdateParameters{} + case string(armcontainerregistry.StepTypeFileTask): + b = &armcontainerregistry.FileTaskStepUpdateParameters{} + default: + b = &armcontainerregistry.TaskStepUpdateParameters{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..af7dd4ed3aa2 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go @@ -0,0 +1,213 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armcontainerregistry.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, registryName string, privateEndpointConnectionName string, privateEndpointConnection armcontainerregistry.PrivateEndpointConnection, options *armcontainerregistry.PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.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, registryName string, privateEndpointConnectionName string, options *armcontainerregistry.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.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, registryName string, privateEndpointConnectionName string, options *armcontainerregistry.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armcontainerregistry.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PrivateEndpointConnectionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.PrivateEndpointConnectionsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.PrivateEndpointConnectionsClientListResponse]) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armcontainerregistry.PrivateEndpointConnectionsClient by way of the +// undefined.Transporter field. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{srv: srv} +} + +// PrivateEndpointConnectionsServerTransport connects instances of armcontainerregistry.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginCreateOrUpdate *azfake.PollerResponder[armcontainerregistry.PrivateEndpointConnectionsClientCreateOrUpdateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.PrivateEndpointConnectionsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.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("method BeginCreateOrUpdate not implemented")} + } + if p.beginCreateOrUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + p.beginCreateOrUpdate = &respr + } + + resp, err := server.PollerResponderNext(p.beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(p.beginCreateOrUpdate) { + p.beginCreateOrUpdate = nil + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if p.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + p.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(p.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(p.beginDelete) { + p.beginDelete = nil + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], 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("method NewListPager not implemented")} + } + if p.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + p.newListPager = &resp + server.PagerResponderInjectNextLinks(p.newListPager, req, func(page *armcontainerregistry.PrivateEndpointConnectionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(p.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(p.newListPager) { + p.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go new file mode 100644 index 000000000000..1e19a5f11d92 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go @@ -0,0 +1,661 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// RegistriesServer is a fake server for instances of the armcontainerregistry.RegistriesClient type. +type RegistriesServer struct { + // CheckNameAvailability is the fake for method RegistriesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, registryNameCheckRequest armcontainerregistry.RegistryNameCheckRequest, options *armcontainerregistry.RegistriesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreate is the fake for method RegistriesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, registry armcontainerregistry.Registry, options *armcontainerregistry.RegistriesClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method RegistriesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginGenerateCredentials is the fake for method RegistriesClient.BeginGenerateCredentials + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateCredentials func(ctx context.Context, resourceGroupName string, registryName string, generateCredentialsParameters armcontainerregistry.GenerateCredentialsParameters, options *armcontainerregistry.RegistriesClientBeginGenerateCredentialsOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientGenerateCredentialsResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RegistriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientGetOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientGetResponse], errResp azfake.ErrorResponder) + + // GetBuildSourceUploadURL is the fake for method RegistriesClient.GetBuildSourceUploadURL + // HTTP status codes to indicate success: http.StatusOK + GetBuildSourceUploadURL func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientGetBuildSourceUploadURLOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientGetBuildSourceUploadURLResponse], errResp azfake.ErrorResponder) + + // GetPrivateLinkResource is the fake for method RegistriesClient.GetPrivateLinkResource + // HTTP status codes to indicate success: http.StatusOK + GetPrivateLinkResource func(ctx context.Context, resourceGroupName string, registryName string, groupName string, options *armcontainerregistry.RegistriesClientGetPrivateLinkResourceOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientGetPrivateLinkResourceResponse], errResp azfake.ErrorResponder) + + // BeginImportImage is the fake for method RegistriesClient.BeginImportImage + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginImportImage func(ctx context.Context, resourceGroupName string, registryName string, parameters armcontainerregistry.ImportImageParameters, options *armcontainerregistry.RegistriesClientBeginImportImageOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientImportImageResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RegistriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcontainerregistry.RegistriesClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.RegistriesClientListResponse]) + + // NewListByResourceGroupPager is the fake for method RegistriesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armcontainerregistry.RegistriesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armcontainerregistry.RegistriesClientListByResourceGroupResponse]) + + // ListCredentials is the fake for method RegistriesClient.ListCredentials + // HTTP status codes to indicate success: http.StatusOK + ListCredentials func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientListCredentialsOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientListCredentialsResponse], errResp azfake.ErrorResponder) + + // NewListPrivateLinkResourcesPager is the fake for method RegistriesClient.NewListPrivateLinkResourcesPager + // HTTP status codes to indicate success: http.StatusOK + NewListPrivateLinkResourcesPager func(resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientListPrivateLinkResourcesOptions) (resp azfake.PagerResponder[armcontainerregistry.RegistriesClientListPrivateLinkResourcesResponse]) + + // ListUsages is the fake for method RegistriesClient.ListUsages + // HTTP status codes to indicate success: http.StatusOK + ListUsages func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistry.RegistriesClientListUsagesOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientListUsagesResponse], errResp azfake.ErrorResponder) + + // RegenerateCredential is the fake for method RegistriesClient.RegenerateCredential + // HTTP status codes to indicate success: http.StatusOK + RegenerateCredential func(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters armcontainerregistry.RegenerateCredentialParameters, options *armcontainerregistry.RegistriesClientRegenerateCredentialOptions) (resp azfake.Responder[armcontainerregistry.RegistriesClientRegenerateCredentialResponse], errResp azfake.ErrorResponder) + + // BeginScheduleRun is the fake for method RegistriesClient.BeginScheduleRun + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginScheduleRun func(ctx context.Context, resourceGroupName string, registryName string, runRequest armcontainerregistry.RunRequestClassification, options *armcontainerregistry.RegistriesClientBeginScheduleRunOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientScheduleRunResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method RegistriesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters armcontainerregistry.RegistryUpdateParameters, options *armcontainerregistry.RegistriesClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.RegistriesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewRegistriesServerTransport creates a new instance of RegistriesServerTransport with the provided implementation. +// The returned RegistriesServerTransport instance is connected to an instance of armcontainerregistry.RegistriesClient by way of the +// undefined.Transporter field. +func NewRegistriesServerTransport(srv *RegistriesServer) *RegistriesServerTransport { + return &RegistriesServerTransport{srv: srv} +} + +// RegistriesServerTransport connects instances of armcontainerregistry.RegistriesClient to instances of RegistriesServer. +// Don't use this type directly, use NewRegistriesServerTransport instead. +type RegistriesServerTransport struct { + srv *RegistriesServer + beginCreate *azfake.PollerResponder[armcontainerregistry.RegistriesClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.RegistriesClientDeleteResponse] + beginGenerateCredentials *azfake.PollerResponder[armcontainerregistry.RegistriesClientGenerateCredentialsResponse] + beginImportImage *azfake.PollerResponder[armcontainerregistry.RegistriesClientImportImageResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.RegistriesClientListResponse] + newListByResourceGroupPager *azfake.PagerResponder[armcontainerregistry.RegistriesClientListByResourceGroupResponse] + newListPrivateLinkResourcesPager *azfake.PagerResponder[armcontainerregistry.RegistriesClientListPrivateLinkResourcesResponse] + beginScheduleRun *azfake.PollerResponder[armcontainerregistry.RegistriesClientScheduleRunResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.RegistriesClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for RegistriesServerTransport. +func (r *RegistriesServerTransport) 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 "RegistriesClient.CheckNameAvailability": + resp, err = r.dispatchCheckNameAvailability(req) + case "RegistriesClient.BeginCreate": + resp, err = r.dispatchBeginCreate(req) + case "RegistriesClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "RegistriesClient.BeginGenerateCredentials": + resp, err = r.dispatchBeginGenerateCredentials(req) + case "RegistriesClient.Get": + resp, err = r.dispatchGet(req) + case "RegistriesClient.GetBuildSourceUploadURL": + resp, err = r.dispatchGetBuildSourceUploadURL(req) + case "RegistriesClient.GetPrivateLinkResource": + resp, err = r.dispatchGetPrivateLinkResource(req) + case "RegistriesClient.BeginImportImage": + resp, err = r.dispatchBeginImportImage(req) + case "RegistriesClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + case "RegistriesClient.NewListByResourceGroupPager": + resp, err = r.dispatchNewListByResourceGroupPager(req) + case "RegistriesClient.ListCredentials": + resp, err = r.dispatchListCredentials(req) + case "RegistriesClient.NewListPrivateLinkResourcesPager": + resp, err = r.dispatchNewListPrivateLinkResourcesPager(req) + case "RegistriesClient.ListUsages": + resp, err = r.dispatchListUsages(req) + case "RegistriesClient.RegenerateCredential": + resp, err = r.dispatchRegenerateCredential(req) + case "RegistriesClient.BeginScheduleRun": + resp, err = r.dispatchBeginScheduleRun(req) + case "RegistriesClient.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 *RegistriesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if r.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("method CheckNameAvailability not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/checkNameAvailability" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.RegistryNameCheckRequest](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).RegistryNameStatus, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if r.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.Registry](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(r.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginCreate) { + r.beginCreate = nil + } + + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if r.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(r.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginDelete) { + r.beginDelete = nil + } + + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchBeginGenerateCredentials(req *http.Request) (*http.Response, error) { + if r.srv.BeginGenerateCredentials == nil { + return nil, &nonRetriableError{errors.New("method BeginGenerateCredentials not implemented")} + } + if r.beginGenerateCredentials == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/generateCredentials" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.GenerateCredentialsParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginGenerateCredentials(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginGenerateCredentials = &respr + } + + resp, err := server.PollerResponderNext(r.beginGenerateCredentials, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginGenerateCredentials) { + r.beginGenerateCredentials = nil + } + + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], 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).Registry, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchGetBuildSourceUploadURL(req *http.Request) (*http.Response, error) { + if r.srv.GetBuildSourceUploadURL == nil { + return nil, &nonRetriableError{errors.New("method GetBuildSourceUploadURL not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listBuildSourceUploadUrl" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.GetBuildSourceUploadURL(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], 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).SourceUploadDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchGetPrivateLinkResource(req *http.Request) (*http.Response, error) { + if r.srv.GetPrivateLinkResource == nil { + return nil, &nonRetriableError{errors.New("method GetPrivateLinkResource not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateLinkResources/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.GetPrivateLinkResource(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("groupName")], 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 (r *RegistriesServerTransport) dispatchBeginImportImage(req *http.Request) (*http.Response, error) { + if r.srv.BeginImportImage == nil { + return nil, &nonRetriableError{errors.New("method BeginImportImage not implemented")} + } + if r.beginImportImage == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importImage" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ImportImageParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginImportImage(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginImportImage = &respr + } + + resp, err := server.PollerResponderNext(r.beginImportImage, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginImportImage) { + r.beginImportImage = nil + } + + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if r.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewListPager(nil) + r.newListPager = &resp + server.PagerResponderInjectNextLinks(r.newListPager, req, func(page *armcontainerregistry.RegistriesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(r.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(r.newListPager) { + r.newListPager = nil + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("method NewListByResourceGroupPager not implemented")} + } + if r.newListByResourceGroupPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewListByResourceGroupPager(matches[regex.SubexpIndex("resourceGroupName")], nil) + r.newListByResourceGroupPager = &resp + server.PagerResponderInjectNextLinks(r.newListByResourceGroupPager, req, func(page *armcontainerregistry.RegistriesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(r.newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(r.newListByResourceGroupPager) { + r.newListByResourceGroupPager = nil + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchListCredentials(req *http.Request) (*http.Response, error) { + if r.srv.ListCredentials == nil { + return nil, &nonRetriableError{errors.New("method ListCredentials not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listCredentials" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.ListCredentials(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], 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).RegistryListCredentialsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchNewListPrivateLinkResourcesPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPrivateLinkResourcesPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPrivateLinkResourcesPager not implemented")} + } + if r.newListPrivateLinkResourcesPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateLinkResources" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewListPrivateLinkResourcesPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + r.newListPrivateLinkResourcesPager = &resp + server.PagerResponderInjectNextLinks(r.newListPrivateLinkResourcesPager, req, func(page *armcontainerregistry.RegistriesClientListPrivateLinkResourcesResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(r.newListPrivateLinkResourcesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(r.newListPrivateLinkResourcesPager) { + r.newListPrivateLinkResourcesPager = nil + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchListUsages(req *http.Request) (*http.Response, error) { + if r.srv.ListUsages == nil { + return nil, &nonRetriableError{errors.New("method ListUsages not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listUsages" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.ListUsages(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], 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).RegistryUsageListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchRegenerateCredential(req *http.Request) (*http.Response, error) { + if r.srv.RegenerateCredential == nil { + return nil, &nonRetriableError{errors.New("method RegenerateCredential not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/regenerateCredential" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.RegenerateCredentialParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.RegenerateCredential(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], 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).RegistryListCredentialsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchBeginScheduleRun(req *http.Request) (*http.Response, error) { + if r.srv.BeginScheduleRun == nil { + return nil, &nonRetriableError{errors.New("method BeginScheduleRun not implemented")} + } + if r.beginScheduleRun == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scheduleRun" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalRunRequestClassification(raw) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginScheduleRun(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginScheduleRun = &respr + } + + resp, err := server.PollerResponderNext(r.beginScheduleRun, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginScheduleRun) { + r.beginScheduleRun = nil + } + + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if r.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.RegistryUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(r.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginUpdate) { + r.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go new file mode 100644 index 000000000000..20e99aa662d0 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go @@ -0,0 +1,257 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// ReplicationsServer is a fake server for instances of the armcontainerregistry.ReplicationsClient type. +type ReplicationsServer struct { + // BeginCreate is the fake for method ReplicationsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication armcontainerregistry.Replication, options *armcontainerregistry.ReplicationsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.ReplicationsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ReplicationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *armcontainerregistry.ReplicationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.ReplicationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ReplicationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *armcontainerregistry.ReplicationsClientGetOptions) (resp azfake.Responder[armcontainerregistry.ReplicationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ReplicationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.ReplicationsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.ReplicationsClientListResponse]) + + // BeginUpdate is the fake for method ReplicationsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters armcontainerregistry.ReplicationUpdateParameters, options *armcontainerregistry.ReplicationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.ReplicationsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewReplicationsServerTransport creates a new instance of ReplicationsServerTransport with the provided implementation. +// The returned ReplicationsServerTransport instance is connected to an instance of armcontainerregistry.ReplicationsClient by way of the +// undefined.Transporter field. +func NewReplicationsServerTransport(srv *ReplicationsServer) *ReplicationsServerTransport { + return &ReplicationsServerTransport{srv: srv} +} + +// ReplicationsServerTransport connects instances of armcontainerregistry.ReplicationsClient to instances of ReplicationsServer. +// Don't use this type directly, use NewReplicationsServerTransport instead. +type ReplicationsServerTransport struct { + srv *ReplicationsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.ReplicationsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.ReplicationsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.ReplicationsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.ReplicationsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for ReplicationsServerTransport. +func (r *ReplicationsServerTransport) 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 "ReplicationsClient.BeginCreate": + resp, err = r.dispatchBeginCreate(req) + case "ReplicationsClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "ReplicationsClient.Get": + resp, err = r.dispatchGet(req) + case "ReplicationsClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + case "ReplicationsClient.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 *ReplicationsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if r.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.Replication](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(r.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginCreate) { + r.beginCreate = nil + } + + return resp, nil +} + +func (r *ReplicationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if r.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(r.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginDelete) { + r.beginDelete = nil + } + + return resp, nil +} + +func (r *ReplicationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], 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).Replication, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ReplicationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if r.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + r.newListPager = &resp + server.PagerResponderInjectNextLinks(r.newListPager, req, func(page *armcontainerregistry.ReplicationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(r.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(r.newListPager) { + r.newListPager = nil + } + return resp, nil +} + +func (r *ReplicationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if r.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ReplicationUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(r.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginUpdate) { + r.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go new file mode 100644 index 000000000000..87b2f546de14 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go @@ -0,0 +1,264 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" + "strconv" +) + +// RunsServer is a fake server for instances of the armcontainerregistry.RunsClient type. +type RunsServer struct { + // BeginCancel is the fake for method RunsClient.BeginCancel + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCancel func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistry.RunsClientBeginCancelOptions) (resp azfake.PollerResponder[armcontainerregistry.RunsClientCancelResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistry.RunsClientGetOptions) (resp azfake.Responder[armcontainerregistry.RunsClientGetResponse], errResp azfake.ErrorResponder) + + // GetLogSasURL is the fake for method RunsClient.GetLogSasURL + // HTTP status codes to indicate success: http.StatusOK + GetLogSasURL func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistry.RunsClientGetLogSasURLOptions) (resp azfake.Responder[armcontainerregistry.RunsClientGetLogSasURLResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.RunsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.RunsClientListResponse]) + + // BeginUpdate is the fake for method RunsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters armcontainerregistry.RunUpdateParameters, options *armcontainerregistry.RunsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.RunsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewRunsServerTransport creates a new instance of RunsServerTransport with the provided implementation. +// The returned RunsServerTransport instance is connected to an instance of armcontainerregistry.RunsClient by way of the +// undefined.Transporter field. +func NewRunsServerTransport(srv *RunsServer) *RunsServerTransport { + return &RunsServerTransport{srv: srv} +} + +// RunsServerTransport connects instances of armcontainerregistry.RunsClient to instances of RunsServer. +// Don't use this type directly, use NewRunsServerTransport instead. +type RunsServerTransport struct { + srv *RunsServer + beginCancel *azfake.PollerResponder[armcontainerregistry.RunsClientCancelResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.RunsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.RunsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for RunsServerTransport. +func (r *RunsServerTransport) 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 "RunsClient.BeginCancel": + resp, err = r.dispatchBeginCancel(req) + case "RunsClient.Get": + resp, err = r.dispatchGet(req) + case "RunsClient.GetLogSasURL": + resp, err = r.dispatchGetLogSasURL(req) + case "RunsClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + case "RunsClient.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 *RunsServerTransport) dispatchBeginCancel(req *http.Request) (*http.Response, error) { + if r.srv.BeginCancel == nil { + return nil, &nonRetriableError{errors.New("method BeginCancel not implemented")} + } + if r.beginCancel == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)/cancel" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.BeginCancel(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginCancel = &respr + } + + resp, err := server.PollerResponderNext(r.beginCancel, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginCancel) { + r.beginCancel = nil + } + + return resp, nil +} + +func (r *RunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], 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).Run, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchGetLogSasURL(req *http.Request) (*http.Response, error) { + if r.srv.GetLogSasURL == nil { + return nil, &nonRetriableError{errors.New("method GetLogSasURL not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)/listLogSasUrl" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := r.srv.GetLogSasURL(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], 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).RunGetLogResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if r.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + filterParam := getOptional(qp.Get("$filter")) + topParam, err := parseOptional(qp.Get("$top"), 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 *armcontainerregistry.RunsClientListOptions + if filterParam != nil || topParam != nil { + options = &armcontainerregistry.RunsClientListOptions{ + Filter: filterParam, + Top: topParam, + } + } + resp := r.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], options) + r.newListPager = &resp + server.PagerResponderInjectNextLinks(r.newListPager, req, func(page *armcontainerregistry.RunsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(r.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(r.newListPager) { + r.newListPager = nil + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if r.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.RunUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + r.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(r.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(r.beginUpdate) { + r.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go new file mode 100644 index 000000000000..41ca708b1fe4 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go @@ -0,0 +1,257 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// ScopeMapsServer is a fake server for instances of the armcontainerregistry.ScopeMapsClient type. +type ScopeMapsServer struct { + // BeginCreate is the fake for method ScopeMapsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapCreateParameters armcontainerregistry.ScopeMap, options *armcontainerregistry.ScopeMapsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.ScopeMapsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ScopeMapsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *armcontainerregistry.ScopeMapsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.ScopeMapsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ScopeMapsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *armcontainerregistry.ScopeMapsClientGetOptions) (resp azfake.Responder[armcontainerregistry.ScopeMapsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ScopeMapsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.ScopeMapsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.ScopeMapsClientListResponse]) + + // BeginUpdate is the fake for method ScopeMapsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapUpdateParameters armcontainerregistry.ScopeMapUpdateParameters, options *armcontainerregistry.ScopeMapsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.ScopeMapsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewScopeMapsServerTransport creates a new instance of ScopeMapsServerTransport with the provided implementation. +// The returned ScopeMapsServerTransport instance is connected to an instance of armcontainerregistry.ScopeMapsClient by way of the +// undefined.Transporter field. +func NewScopeMapsServerTransport(srv *ScopeMapsServer) *ScopeMapsServerTransport { + return &ScopeMapsServerTransport{srv: srv} +} + +// ScopeMapsServerTransport connects instances of armcontainerregistry.ScopeMapsClient to instances of ScopeMapsServer. +// Don't use this type directly, use NewScopeMapsServerTransport instead. +type ScopeMapsServerTransport struct { + srv *ScopeMapsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.ScopeMapsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.ScopeMapsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.ScopeMapsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.ScopeMapsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for ScopeMapsServerTransport. +func (s *ScopeMapsServerTransport) 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 "ScopeMapsClient.BeginCreate": + resp, err = s.dispatchBeginCreate(req) + case "ScopeMapsClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "ScopeMapsClient.Get": + resp, err = s.dispatchGet(req) + case "ScopeMapsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + case "ScopeMapsClient.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 *ScopeMapsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if s.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ScopeMap](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + s.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(s.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(s.beginCreate) { + s.beginCreate = nil + } + + return resp, nil +} + +func (s *ScopeMapsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if s.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + s.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(s.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(s.beginDelete) { + s.beginDelete = nil + } + + return resp, nil +} + +func (s *ScopeMapsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], 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).ScopeMap, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScopeMapsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if s.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + s.newListPager = &resp + server.PagerResponderInjectNextLinks(s.newListPager, req, func(page *armcontainerregistry.ScopeMapsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(s.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(s.newListPager) { + s.newListPager = nil + } + return resp, nil +} + +func (s *ScopeMapsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if s.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.ScopeMapUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + s.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(s.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(s.beginUpdate) { + s.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go new file mode 100644 index 000000000000..80bf4519db32 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go @@ -0,0 +1,288 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// TaskRunsServer is a fake server for instances of the armcontainerregistry.TaskRunsClient type. +type TaskRunsServer struct { + // BeginCreate is the fake for method TaskRunsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun armcontainerregistry.TaskRun, options *armcontainerregistry.TaskRunsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.TaskRunsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TaskRunsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistry.TaskRunsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.TaskRunsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TaskRunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistry.TaskRunsClientGetOptions) (resp azfake.Responder[armcontainerregistry.TaskRunsClientGetResponse], errResp azfake.ErrorResponder) + + // GetDetails is the fake for method TaskRunsClient.GetDetails + // HTTP status codes to indicate success: http.StatusOK + GetDetails func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistry.TaskRunsClientGetDetailsOptions) (resp azfake.Responder[armcontainerregistry.TaskRunsClientGetDetailsResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TaskRunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.TaskRunsClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.TaskRunsClientListResponse]) + + // BeginUpdate is the fake for method TaskRunsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters armcontainerregistry.TaskRunUpdateParameters, options *armcontainerregistry.TaskRunsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.TaskRunsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTaskRunsServerTransport creates a new instance of TaskRunsServerTransport with the provided implementation. +// The returned TaskRunsServerTransport instance is connected to an instance of armcontainerregistry.TaskRunsClient by way of the +// undefined.Transporter field. +func NewTaskRunsServerTransport(srv *TaskRunsServer) *TaskRunsServerTransport { + return &TaskRunsServerTransport{srv: srv} +} + +// TaskRunsServerTransport connects instances of armcontainerregistry.TaskRunsClient to instances of TaskRunsServer. +// Don't use this type directly, use NewTaskRunsServerTransport instead. +type TaskRunsServerTransport struct { + srv *TaskRunsServer + beginCreate *azfake.PollerResponder[armcontainerregistry.TaskRunsClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.TaskRunsClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.TaskRunsClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.TaskRunsClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for TaskRunsServerTransport. +func (t *TaskRunsServerTransport) 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 "TaskRunsClient.BeginCreate": + resp, err = t.dispatchBeginCreate(req) + case "TaskRunsClient.BeginDelete": + resp, err = t.dispatchBeginDelete(req) + case "TaskRunsClient.Get": + resp, err = t.dispatchGet(req) + case "TaskRunsClient.GetDetails": + resp, err = t.dispatchGetDetails(req) + case "TaskRunsClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + case "TaskRunsClient.BeginUpdate": + resp, err = t.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if t.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.TaskRun](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(t.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginCreate) { + t.beginCreate = nil + } + + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if t.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(t.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginDelete) { + t.beginDelete = nil + } + + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], 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).TaskRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { + if t.srv.GetDetails == nil { + return nil, &nonRetriableError{errors.New("method GetDetails not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)/listDetails" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.GetDetails(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], 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).TaskRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if t.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + t.newListPager = &resp + server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TaskRunsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(t.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(t.newListPager) { + t.newListPager = nil + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if t.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.TaskRunUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(t.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginUpdate) { + t.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go new file mode 100644 index 000000000000..2502d890dd25 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go @@ -0,0 +1,288 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// TasksServer is a fake server for instances of the armcontainerregistry.TasksClient type. +type TasksServer struct { + // BeginCreate is the fake for method TasksClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters armcontainerregistry.Task, options *armcontainerregistry.TasksClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.TasksClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TasksClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistry.TasksClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.TasksClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TasksClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistry.TasksClientGetOptions) (resp azfake.Responder[armcontainerregistry.TasksClientGetResponse], errResp azfake.ErrorResponder) + + // GetDetails is the fake for method TasksClient.GetDetails + // HTTP status codes to indicate success: http.StatusOK + GetDetails func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistry.TasksClientGetDetailsOptions) (resp azfake.Responder[armcontainerregistry.TasksClientGetDetailsResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TasksClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.TasksClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.TasksClientListResponse]) + + // BeginUpdate is the fake for method TasksClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters armcontainerregistry.TaskUpdateParameters, options *armcontainerregistry.TasksClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.TasksClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTasksServerTransport creates a new instance of TasksServerTransport with the provided implementation. +// The returned TasksServerTransport instance is connected to an instance of armcontainerregistry.TasksClient by way of the +// undefined.Transporter field. +func NewTasksServerTransport(srv *TasksServer) *TasksServerTransport { + return &TasksServerTransport{srv: srv} +} + +// TasksServerTransport connects instances of armcontainerregistry.TasksClient to instances of TasksServer. +// Don't use this type directly, use NewTasksServerTransport instead. +type TasksServerTransport struct { + srv *TasksServer + beginCreate *azfake.PollerResponder[armcontainerregistry.TasksClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.TasksClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.TasksClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.TasksClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for TasksServerTransport. +func (t *TasksServerTransport) 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 "TasksClient.BeginCreate": + resp, err = t.dispatchBeginCreate(req) + case "TasksClient.BeginDelete": + resp, err = t.dispatchBeginDelete(req) + case "TasksClient.Get": + resp, err = t.dispatchGet(req) + case "TasksClient.GetDetails": + resp, err = t.dispatchGetDetails(req) + case "TasksClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + case "TasksClient.BeginUpdate": + resp, err = t.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TasksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if t.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.Task](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(t.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginCreate) { + t.beginCreate = nil + } + + return resp, nil +} + +func (t *TasksServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if t.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(t.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginDelete) { + t.beginDelete = nil + } + + return resp, nil +} + +func (t *TasksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], 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).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { + if t.srv.GetDetails == nil { + return nil, &nonRetriableError{errors.New("method GetDetails not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)/listDetails" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.GetDetails(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], 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).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if t.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + t.newListPager = &resp + server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TasksClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(t.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(t.newListPager) { + t.newListPager = nil + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if t.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.TaskUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(t.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginUpdate) { + t.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/time_rfc3339.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/time_rfc3339.go new file mode 100644 index 000000000000..45fe10cbc6df --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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" +) + +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 + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(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] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + 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/containerregistry/armcontainerregistry/fake/tokens_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go new file mode 100644 index 000000000000..8518ef7175f9 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go @@ -0,0 +1,257 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// TokensServer is a fake server for instances of the armcontainerregistry.TokensClient type. +type TokensServer struct { + // BeginCreate is the fake for method TokensClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenCreateParameters armcontainerregistry.Token, options *armcontainerregistry.TokensClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.TokensClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TokensClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *armcontainerregistry.TokensClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.TokensClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TokensClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *armcontainerregistry.TokensClientGetOptions) (resp azfake.Responder[armcontainerregistry.TokensClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TokensClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.TokensClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.TokensClientListResponse]) + + // BeginUpdate is the fake for method TokensClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenUpdateParameters armcontainerregistry.TokenUpdateParameters, options *armcontainerregistry.TokensClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.TokensClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTokensServerTransport creates a new instance of TokensServerTransport with the provided implementation. +// The returned TokensServerTransport instance is connected to an instance of armcontainerregistry.TokensClient by way of the +// undefined.Transporter field. +func NewTokensServerTransport(srv *TokensServer) *TokensServerTransport { + return &TokensServerTransport{srv: srv} +} + +// TokensServerTransport connects instances of armcontainerregistry.TokensClient to instances of TokensServer. +// Don't use this type directly, use NewTokensServerTransport instead. +type TokensServerTransport struct { + srv *TokensServer + beginCreate *azfake.PollerResponder[armcontainerregistry.TokensClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.TokensClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.TokensClientListResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.TokensClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for TokensServerTransport. +func (t *TokensServerTransport) 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 "TokensClient.BeginCreate": + resp, err = t.dispatchBeginCreate(req) + case "TokensClient.BeginDelete": + resp, err = t.dispatchBeginDelete(req) + case "TokensClient.Get": + resp, err = t.dispatchGet(req) + case "TokensClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + case "TokensClient.BeginUpdate": + resp, err = t.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TokensServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if t.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.Token](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(t.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginCreate) { + t.beginCreate = nil + } + + return resp, nil +} + +func (t *TokensServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if t.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(t.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginDelete) { + t.beginDelete = nil + } + + return resp, nil +} + +func (t *TokensServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], 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).Token, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TokensServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if t.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + t.newListPager = &resp + server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TokensClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(t.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(t.newListPager) { + t.newListPager = nil + } + return resp, nil +} + +func (t *TokensServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if t.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.TokenUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + t.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(t.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(t.beginUpdate) { + t.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go new file mode 100644 index 000000000000..fef24f062e4c --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go @@ -0,0 +1,356 @@ +//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/containerregistry/armcontainerregistry" + "net/http" + "regexp" +) + +// WebhooksServer is a fake server for instances of the armcontainerregistry.WebhooksClient type. +type WebhooksServer struct { + // BeginCreate is the fake for method WebhooksClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters armcontainerregistry.WebhookCreateParameters, options *armcontainerregistry.WebhooksClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistry.WebhooksClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method WebhooksClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *armcontainerregistry.WebhooksClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistry.WebhooksClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WebhooksClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *armcontainerregistry.WebhooksClientGetOptions) (resp azfake.Responder[armcontainerregistry.WebhooksClientGetResponse], errResp azfake.ErrorResponder) + + // GetCallbackConfig is the fake for method WebhooksClient.GetCallbackConfig + // HTTP status codes to indicate success: http.StatusOK + GetCallbackConfig func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *armcontainerregistry.WebhooksClientGetCallbackConfigOptions) (resp azfake.Responder[armcontainerregistry.WebhooksClientGetCallbackConfigResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WebhooksClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistry.WebhooksClientListOptions) (resp azfake.PagerResponder[armcontainerregistry.WebhooksClientListResponse]) + + // NewListEventsPager is the fake for method WebhooksClient.NewListEventsPager + // HTTP status codes to indicate success: http.StatusOK + NewListEventsPager func(resourceGroupName string, registryName string, webhookName string, options *armcontainerregistry.WebhooksClientListEventsOptions) (resp azfake.PagerResponder[armcontainerregistry.WebhooksClientListEventsResponse]) + + // Ping is the fake for method WebhooksClient.Ping + // HTTP status codes to indicate success: http.StatusOK + Ping func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *armcontainerregistry.WebhooksClientPingOptions) (resp azfake.Responder[armcontainerregistry.WebhooksClientPingResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method WebhooksClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters armcontainerregistry.WebhookUpdateParameters, options *armcontainerregistry.WebhooksClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistry.WebhooksClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWebhooksServerTransport creates a new instance of WebhooksServerTransport with the provided implementation. +// The returned WebhooksServerTransport instance is connected to an instance of armcontainerregistry.WebhooksClient by way of the +// undefined.Transporter field. +func NewWebhooksServerTransport(srv *WebhooksServer) *WebhooksServerTransport { + return &WebhooksServerTransport{srv: srv} +} + +// WebhooksServerTransport connects instances of armcontainerregistry.WebhooksClient to instances of WebhooksServer. +// Don't use this type directly, use NewWebhooksServerTransport instead. +type WebhooksServerTransport struct { + srv *WebhooksServer + beginCreate *azfake.PollerResponder[armcontainerregistry.WebhooksClientCreateResponse] + beginDelete *azfake.PollerResponder[armcontainerregistry.WebhooksClientDeleteResponse] + newListPager *azfake.PagerResponder[armcontainerregistry.WebhooksClientListResponse] + newListEventsPager *azfake.PagerResponder[armcontainerregistry.WebhooksClientListEventsResponse] + beginUpdate *azfake.PollerResponder[armcontainerregistry.WebhooksClientUpdateResponse] +} + +// Do implements the policy.Transporter interface for WebhooksServerTransport. +func (w *WebhooksServerTransport) 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 "WebhooksClient.BeginCreate": + resp, err = w.dispatchBeginCreate(req) + case "WebhooksClient.BeginDelete": + resp, err = w.dispatchBeginDelete(req) + case "WebhooksClient.Get": + resp, err = w.dispatchGet(req) + case "WebhooksClient.GetCallbackConfig": + resp, err = w.dispatchGetCallbackConfig(req) + case "WebhooksClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WebhooksClient.NewListEventsPager": + resp, err = w.dispatchNewListEventsPager(req) + case "WebhooksClient.Ping": + resp, err = w.dispatchPing(req) + case "WebhooksClient.BeginUpdate": + resp, err = w.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if w.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.WebhookCreateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + w.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(w.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(w.beginCreate) { + w.beginCreate = nil + } + + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if w.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + } + if w.beginDelete == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := w.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + w.beginDelete = &respr + } + + resp, err := server.PollerResponderNext(w.beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(w.beginDelete) { + w.beginDelete = nil + } + + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := w.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], 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).Webhook, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchGetCallbackConfig(req *http.Request) (*http.Response, error) { + if w.srv.GetCallbackConfig == nil { + return nil, &nonRetriableError{errors.New("method GetCallbackConfig not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/getCallbackConfig" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := w.srv.GetCallbackConfig(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], 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).CallbackConfig, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if w.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := w.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + w.newListPager = &resp + server.PagerResponderInjectNextLinks(w.newListPager, req, func(page *armcontainerregistry.WebhooksClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(w.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(w.newListPager) { + w.newListPager = nil + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchNewListEventsPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListEventsPager == nil { + return nil, &nonRetriableError{errors.New("method NewListEventsPager not implemented")} + } + if w.newListEventsPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/listEvents" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := w.srv.NewListEventsPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + w.newListEventsPager = &resp + server.PagerResponderInjectNextLinks(w.newListEventsPager, req, func(page *armcontainerregistry.WebhooksClientListEventsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(w.newListEventsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(w.newListEventsPager) { + w.newListEventsPager = nil + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchPing(req *http.Request) (*http.Response, error) { + if w.srv.Ping == nil { + return nil, &nonRetriableError{errors.New("method Ping not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/ping" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := w.srv.Ping(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], 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).EventInfo, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WebhooksServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + } + if w.beginUpdate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistry.WebhookUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + w.beginUpdate = &respr + } + + resp, err := server.PollerResponderNext(w.beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(w.beginUpdate) { + w.beginUpdate = nil + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/go.mod b/sdk/resourcemanager/containerregistry/armcontainerregistry/go.mod index 31324df30464..31becb3d4c3e 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/go.mod +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/go.mod @@ -3,14 +3,14 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/a go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0-beta.2 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 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + 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.9.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -21,9 +21,9 @@ require ( 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/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/go.sum b/sdk/resourcemanager/containerregistry/armcontainerregistry/go.sum index 6e2c77825a2c..4ab9e273d0e2 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/go.sum +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/go.sum @@ -1,9 +1,9 @@ -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/azcore v1.7.0-beta.2 h1:C3zKsGguxcLd8a2uEytB8+TFtBGd75bXRxEs0QBwsv0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0-beta.2/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.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/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/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= @@ -31,13 +31,13 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.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= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.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.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= 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= diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/importpipelines_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/importpipelines_client.go index 3073c0e2a9f4..9f586ca37df7 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/importpipelines_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/importpipelines_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *ImportPipelinesClient) BeginCreate(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImportPipelinesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImportPipelinesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ImportPipelinesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *ImportPipelinesClient) BeginCreate(ctx context.Context, resourceGr // // Generated from API version 2023-01-01-preview func (client *ImportPipelinesClient) create(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, importPipelineCreateParameters ImportPipeline, options *ImportPipelinesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ImportPipelinesClient.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, registryName, importPipelineName, importPipelineCreateParameters, 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. @@ -111,7 +117,10 @@ func (client *ImportPipelinesClient) createCreateRequest(ctx context.Context, re reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, importPipelineCreateParameters) + if err := runtime.MarshalAsJSON(req, importPipelineCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes an import pipeline from a container registry. @@ -129,9 +138,10 @@ func (client *ImportPipelinesClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImportPipelinesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ImportPipelinesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ImportPipelinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *ImportPipelinesClient) BeginDelete(ctx context.Context, resourceGr // // Generated from API version 2023-01-01-preview func (client *ImportPipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ImportPipelinesClient.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, registryName, importPipelineName, 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. @@ -192,18 +208,25 @@ func (client *ImportPipelinesClient) deleteCreateRequest(ctx context.Context, re // - importPipelineName - The name of the import pipeline. // - options - ImportPipelinesClientGetOptions contains the optional parameters for the ImportPipelinesClient.Get method. func (client *ImportPipelinesClient) Get(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesClientGetOptions) (ImportPipelinesClientGetResponse, error) { + var err error + const operationName = "ImportPipelinesClient.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, registryName, importPipelineName, options) if err != nil { return ImportPipelinesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ImportPipelinesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ImportPipelinesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ImportPipelinesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -255,6 +278,7 @@ func (client *ImportPipelinesClient) NewListPager(resourceGroupName string, regi return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ImportPipelinesClientListResponse) (ImportPipelinesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ImportPipelinesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -274,6 +298,7 @@ func (client *ImportPipelinesClient) NewListPager(resourceGroupName string, regi } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/models.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/models.go index 8fa8c93d2619..5fdac611e903 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/models.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry @@ -14,96 +13,96 @@ import "time" // ActivationProperties - The activation properties of the connected registry. type ActivationProperties struct { // READ-ONLY; The activation status of the connected registry. - Status *ActivationStatus `json:"status,omitempty" azure:"ro"` + Status *ActivationStatus } // ActiveDirectoryObject - The Active Directory Object that will be used for authenticating the token of a container registry. type ActiveDirectoryObject struct { // The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container // registry. - ObjectID *string `json:"objectId,omitempty"` + ObjectID *string // The tenant ID of user/group/application object Active Directory Object that will be used for authenticating the token of // a container registry. - TenantID *string `json:"tenantId,omitempty"` + TenantID *string } // Actor - The agent that initiated the event. For most situations, this could be from the authorization context of the request. type Actor struct { // The subject or username associated with the request context that generated the event. - Name *string `json:"name,omitempty"` + Name *string } // AgentPool - The agentpool that has the ARM resource and properties. The agentpool will have all information to create an // agent pool. type AgentPool struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // The properties associated with the agent pool - Properties *AgentPoolProperties `json:"properties,omitempty"` + Properties *AgentPoolProperties // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // AgentPoolListResult - The collection of agent pools. type AgentPoolListResult struct { // The URI that can be used to request the next set of paged results. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The collection value. - Value []*AgentPool `json:"value,omitempty"` + Value []*AgentPool } // AgentPoolProperties - The properties of agent pool. type AgentPoolProperties struct { // The count of agent machine - Count *int32 `json:"count,omitempty"` + Count *int32 // The OS of agent machine - OS *OS `json:"os,omitempty"` + OS *OS // The Tier of agent machine - Tier *string `json:"tier,omitempty"` + Tier *string // The Virtual Network Subnet Resource Id of the agent machine - VirtualNetworkSubnetResourceID *string `json:"virtualNetworkSubnetResourceId,omitempty"` + VirtualNetworkSubnetResourceID *string // READ-ONLY; The provisioning state of this agent pool - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } type AgentPoolPropertiesUpdateParameters struct { // The count of agent machine - Count *int32 `json:"count,omitempty"` + Count *int32 } // AgentPoolQueueStatus - The QueueStatus of Agent Pool type AgentPoolQueueStatus struct { // The number of pending runs in the queue - Count *int32 `json:"count,omitempty"` + Count *int32 } // AgentPoolUpdateParameters - The parameters for updating an agent pool. type AgentPoolUpdateParameters struct { // The properties associated with the agent pool - Properties *AgentPoolPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *AgentPoolPropertiesUpdateParameters // The ARM resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // AgentPoolsClientBeginCreateOptions contains the optional parameters for the AgentPoolsClient.BeginCreate method. @@ -142,178 +141,178 @@ type AgentPoolsClientListOptions struct { // AgentProperties - The properties that determine the run agent configuration. type AgentProperties struct { // The CPU configuration in terms of number of cores required for the run. - CPU *int32 `json:"cpu,omitempty"` + CPU *int32 } // Argument - The properties of a run argument. type Argument struct { // REQUIRED; The name of the argument. - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; The value of the argument. - Value *string `json:"value,omitempty"` + Value *string // Flag to indicate whether the argument represents a secret and want to be removed from build logs. - IsSecret *bool `json:"isSecret,omitempty"` + IsSecret *bool } // AuthCredential - Authentication credential stored for an upstream. type AuthCredential struct { // The name of the credential. - Name *CredentialName `json:"name,omitempty"` + Name *CredentialName // KeyVault Secret URI for accessing the password. - PasswordSecretIdentifier *string `json:"passwordSecretIdentifier,omitempty"` + PasswordSecretIdentifier *string // KeyVault Secret URI for accessing the username. - UsernameSecretIdentifier *string `json:"usernameSecretIdentifier,omitempty"` + UsernameSecretIdentifier *string // READ-ONLY; This provides data pertaining to the health of the auth credential. - CredentialHealth *CredentialHealth `json:"credentialHealth,omitempty" azure:"ro"` + CredentialHealth *CredentialHealth } // AuthInfo - The authorization properties for accessing the source code repository. type AuthInfo struct { // REQUIRED; The access token used to access the source control provider. - Token *string `json:"token,omitempty"` + Token *string // REQUIRED; The type of Auth token. - TokenType *TokenType `json:"tokenType,omitempty"` + TokenType *TokenType // Time in seconds that the token remains valid - ExpiresIn *int32 `json:"expiresIn,omitempty"` + ExpiresIn *int32 // The refresh token used to refresh the access token. - RefreshToken *string `json:"refreshToken,omitempty"` + RefreshToken *string // The scope of the access token. - Scope *string `json:"scope,omitempty"` + Scope *string } // AuthInfoUpdateParameters - The authorization properties for accessing the source code repository. type AuthInfoUpdateParameters struct { // Time in seconds that the token remains valid - ExpiresIn *int32 `json:"expiresIn,omitempty"` + ExpiresIn *int32 // The refresh token used to refresh the access token. - RefreshToken *string `json:"refreshToken,omitempty"` + RefreshToken *string // The scope of the access token. - Scope *string `json:"scope,omitempty"` + Scope *string // The access token used to access the source control provider. - Token *string `json:"token,omitempty"` + Token *string // The type of Auth token. - TokenType *TokenType `json:"tokenType,omitempty"` + TokenType *TokenType } // AzureADAuthenticationAsArmPolicy - The policy for using ARM audience token for a container registry. type AzureADAuthenticationAsArmPolicy struct { // The value that indicates whether the policy is enabled or not. - Status *AzureADAuthenticationAsArmPolicyStatus `json:"status,omitempty"` + Status *AzureADAuthenticationAsArmPolicyStatus } // BaseImageDependency - Properties that describe a base image dependency. type BaseImageDependency struct { // The sha256-based digest of the image manifest. - Digest *string `json:"digest,omitempty"` + Digest *string // The registry login server. - Registry *string `json:"registry,omitempty"` + Registry *string // The repository name. - Repository *string `json:"repository,omitempty"` + Repository *string // The tag name. - Tag *string `json:"tag,omitempty"` + Tag *string // The type of the base image dependency. - Type *BaseImageDependencyType `json:"type,omitempty"` + Type *BaseImageDependencyType } // BaseImageTrigger - The trigger based on base image dependency. type BaseImageTrigger struct { // REQUIRED; The type of the auto trigger for base image dependency updates. - BaseImageTriggerType *BaseImageTriggerType `json:"baseImageTriggerType,omitempty"` + BaseImageTriggerType *BaseImageTriggerType // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus // The endpoint URL for receiving update triggers. - UpdateTriggerEndpoint *string `json:"updateTriggerEndpoint,omitempty"` + UpdateTriggerEndpoint *string // Type of Payload body for Base image update triggers. - UpdateTriggerPayloadType *UpdateTriggerPayloadType `json:"updateTriggerPayloadType,omitempty"` + UpdateTriggerPayloadType *UpdateTriggerPayloadType } // BaseImageTriggerUpdateParameters - The properties for updating base image dependency trigger. type BaseImageTriggerUpdateParameters struct { // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // The type of the auto trigger for base image dependency updates. - BaseImageTriggerType *BaseImageTriggerType `json:"baseImageTriggerType,omitempty"` + BaseImageTriggerType *BaseImageTriggerType // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus // The endpoint URL for receiving update triggers. - UpdateTriggerEndpoint *string `json:"updateTriggerEndpoint,omitempty"` + UpdateTriggerEndpoint *string // Type of Payload body for Base image update triggers. - UpdateTriggerPayloadType *UpdateTriggerPayloadType `json:"updateTriggerPayloadType,omitempty"` + UpdateTriggerPayloadType *UpdateTriggerPayloadType } // CacheRule - An object that represents a cache rule for a container registry. type CacheRule struct { // The properties of the cache rule. - Properties *CacheRuleProperties `json:"properties,omitempty"` + Properties *CacheRuleProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // CacheRuleProperties - The properties of a cache rule. type CacheRuleProperties struct { // The ARM resource ID of the credential store which is associated with the cache rule. - CredentialSetResourceID *string `json:"credentialSetResourceId,omitempty"` + CredentialSetResourceID *string // Source repository pulled from upstream. - SourceRepository *string `json:"sourceRepository,omitempty"` + SourceRepository *string // Target repository specified in docker pull command. Eg: docker pull myregistry.azurecr.io/{targetRepository}:{tag} - TargetRepository *string `json:"targetRepository,omitempty"` + TargetRepository *string // READ-ONLY; The creation date of the cache rule. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; Provisioning state of the resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // CacheRuleUpdateParameters - The parameters for updating a cache rule. type CacheRuleUpdateParameters struct { // The properties of the cache rule update parameters. - Properties *CacheRuleUpdateProperties `json:"properties,omitempty"` + Properties *CacheRuleUpdateProperties } // CacheRuleUpdateProperties - The parameters for updating cache rule properties. type CacheRuleUpdateProperties struct { // The ARM resource ID of the credential store which is associated with the Cache rule. - CredentialSetResourceID *string `json:"credentialSetResourceId,omitempty"` + CredentialSetResourceID *string } // CacheRulesClientBeginCreateOptions contains the optional parameters for the CacheRulesClient.BeginCreate method. @@ -347,19 +346,19 @@ type CacheRulesClientListOptions struct { // CacheRulesListResult - The result of a request to list cache rules for a container registry. type CacheRulesListResult struct { // If provided, client must use NextLink URI to request next list of cache rules. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of cache rules. - Value []*CacheRule `json:"value,omitempty"` + Value []*CacheRule } // CallbackConfig - The configuration of service URI and custom headers for the webhook. type CallbackConfig struct { // REQUIRED; The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` + ServiceURI *string // Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders,omitempty"` + CustomHeaders map[string]*string } // ConnectedRegistriesClientBeginCreateOptions contains the optional parameters for the ConnectedRegistriesClient.BeginCreate @@ -406,162 +405,162 @@ type ConnectedRegistriesClientListOptions struct { // ConnectedRegistry - An object that represents a connected registry for a container registry. type ConnectedRegistry struct { // The properties of the connected registry. - Properties *ConnectedRegistryProperties `json:"properties,omitempty"` + Properties *ConnectedRegistryProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ConnectedRegistryListResult - The result of a request to list connected registries for a container registry. type ConnectedRegistryListResult struct { // The URI that can be used to request the next list of connected registries. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of connected registries. Since this list may be incomplete, the nextLink field should be used to request the next // list of connected registries. - Value []*ConnectedRegistry `json:"value,omitempty"` + Value []*ConnectedRegistry } // ConnectedRegistryProperties - The properties of a connected registry. type ConnectedRegistryProperties struct { // REQUIRED; The mode of the connected registry resource that indicates the permissions of the registry. - Mode *ConnectedRegistryMode `json:"mode,omitempty"` + Mode *ConnectedRegistryMode // REQUIRED; The parent of the connected registry. - Parent *ParentProperties `json:"parent,omitempty"` + Parent *ParentProperties // The list of the ACR token resource IDs used to authenticate clients to the connected registry. - ClientTokenIDs []*string `json:"clientTokenIds,omitempty"` + ClientTokenIDs []*string // The logging properties of the connected registry. - Logging *LoggingProperties `json:"logging,omitempty"` + Logging *LoggingProperties // The login server properties of the connected registry. - LoginServer *LoginServerProperties `json:"loginServer,omitempty"` + LoginServer *LoginServerProperties // The list of notifications subscription information for the connected registry. - NotificationsList []*string `json:"notificationsList,omitempty"` + NotificationsList []*string // READ-ONLY; The activation properties of the connected registry. - Activation *ActivationProperties `json:"activation,omitempty" azure:"ro"` + Activation *ActivationProperties // READ-ONLY; The current connection state of the connected registry. - ConnectionState *ConnectionState `json:"connectionState,omitempty" azure:"ro"` + ConnectionState *ConnectionState // READ-ONLY; The last activity time of the connected registry. - LastActivityTime *time.Time `json:"lastActivityTime,omitempty" azure:"ro"` + LastActivityTime *time.Time // READ-ONLY; Provisioning state of the resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The list of current statuses of the connected registry. - StatusDetails []*StatusDetailProperties `json:"statusDetails,omitempty" azure:"ro"` + StatusDetails []*StatusDetailProperties // READ-ONLY; The current version of ACR runtime on the connected registry. - Version *string `json:"version,omitempty" azure:"ro"` + Version *string } // ConnectedRegistryUpdateParameters - The parameters for updating a connected registry. type ConnectedRegistryUpdateParameters struct { // The properties of the connected registry update parameters. - Properties *ConnectedRegistryUpdateProperties `json:"properties,omitempty"` + Properties *ConnectedRegistryUpdateProperties } // ConnectedRegistryUpdateProperties - The parameters for updating token properties. type ConnectedRegistryUpdateProperties struct { // The list of the ACR token resource IDs used to authenticate clients to the connected registry. - ClientTokenIDs []*string `json:"clientTokenIds,omitempty"` + ClientTokenIDs []*string // The logging properties of the connected registry. - Logging *LoggingProperties `json:"logging,omitempty"` + Logging *LoggingProperties // The list of notifications subscription information for the connected registry. - NotificationsList []*string `json:"notificationsList,omitempty"` + NotificationsList []*string // The sync properties of the connected registry with its parent. - SyncProperties *SyncUpdateProperties `json:"syncProperties,omitempty"` + SyncProperties *SyncUpdateProperties } // CredentialHealth - The health of the auth credential. type CredentialHealth struct { // Error code representing the health check error. - ErrorCode *string `json:"errorCode,omitempty"` + ErrorCode *string // Descriptive message representing the health check error. - ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessage *string // The health status of credential. - Status *CredentialHealthStatus `json:"status,omitempty"` + Status *CredentialHealthStatus } // CredentialSet - An object that represents a credential set resource for a container registry. type CredentialSet struct { // Identities associated with the resource. This is used to access the KeyVault secrets. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties of the credential set. - Properties *CredentialSetProperties `json:"properties,omitempty"` + Properties *CredentialSetProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // CredentialSetListResult - The result of a request to list credential sets for a container registry. type CredentialSetListResult struct { // The URI that can be used to request the next list of credential sets. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of credential sets. Since this list may be incomplete, the nextLink field should be used to request the next list // of credential sets. - Value []*CredentialSet `json:"value,omitempty"` + Value []*CredentialSet } // CredentialSetProperties - The properties of a credential set resource. type CredentialSetProperties struct { // List of authentication credentials stored for an upstream. Usually consists of a primary and an optional secondary credential. - AuthCredentials []*AuthCredential `json:"authCredentials,omitempty"` + AuthCredentials []*AuthCredential // The credentials are stored for this upstream or login server. - LoginServer *string `json:"loginServer,omitempty"` + LoginServer *string // READ-ONLY; The creation date of credential store resource. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; Provisioning state of the resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // CredentialSetUpdateParameters - The parameters for updating a credential set type CredentialSetUpdateParameters struct { // Identities associated with the resource. This is used to access the KeyVault secrets. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties of the credential set update parameters - Properties *CredentialSetUpdateProperties `json:"properties,omitempty"` + Properties *CredentialSetUpdateProperties } // CredentialSetUpdateProperties - The parameters for updating credential set properties. type CredentialSetUpdateProperties struct { // List of authentication credentials stored for an upstream. Usually consists of a primary and an optional secondary credential. - AuthCredentials []*AuthCredential `json:"authCredentials,omitempty"` + AuthCredentials []*AuthCredential } // CredentialSetsClientBeginCreateOptions contains the optional parameters for the CredentialSetsClient.BeginCreate method. @@ -597,10 +596,10 @@ type Credentials struct { // Describes the credential parameters for accessing other custom registries. The key for the dictionary item will be the // registry login server (myregistry.azurecr.io) and the value of the item will be // the registry credentials for accessing the registry. - CustomRegistries map[string]*CustomRegistryCredentials `json:"customRegistries,omitempty"` + CustomRegistries map[string]*CustomRegistryCredentials // Describes the credential parameters for accessing the source registry. - SourceRegistry *SourceRegistryCredentials `json:"sourceRegistry,omitempty"` + SourceRegistry *SourceRegistryCredentials } // CustomRegistryCredentials - Describes the credentials that will be used to access a custom registry during a run. @@ -610,63 +609,63 @@ type CustomRegistryCredentials struct { // system-assigned identity, the Client ID will be determined by the runner. This identity may be used to authenticate to // key vault to retrieve credentials or it may be the only source of authentication // used for accessing the registry. - Identity *string `json:"identity,omitempty"` + Identity *string // The password for logging into the custom registry. The password is a secret object that allows multiple ways of providing // the value for it. - Password *SecretObject `json:"password,omitempty"` + Password *SecretObject // The username for logging into the custom registry. - UserName *SecretObject `json:"userName,omitempty"` + UserName *SecretObject } // DockerBuildRequest - The parameters for a docker quick build. type DockerBuildRequest struct { // REQUIRED; The Docker file path relative to the source location. - DockerFilePath *string `json:"dockerFilePath,omitempty"` + DockerFilePath *string // REQUIRED; The platform properties against which the run has to happen. - Platform *PlatformProperties `json:"platform,omitempty"` + Platform *PlatformProperties // REQUIRED; The type of the run request. - Type *string `json:"type,omitempty"` + Type *string // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The collection of override arguments to be used when executing the run. - Arguments []*Argument `json:"arguments,omitempty"` + Arguments []*Argument // The properties that describes a set of credentials that will be used when this run is invoked. - Credentials *Credentials `json:"credentials,omitempty"` + Credentials *Credentials // The fully qualified image names including the repository and tag. - ImageNames []*string `json:"imageNames,omitempty"` + ImageNames []*string // The value that indicates whether archiving is enabled for the run or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The value of this property indicates whether the image built should be pushed to the registry or not. - IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + IsPushEnabled *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // The value of this property indicates whether the image cache is enabled or not. - NoCache *bool `json:"noCache,omitempty"` + NoCache *bool // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, // the relative path should be obtained from calling listBuildSourceUploadUrl API. - SourceLocation *string `json:"sourceLocation,omitempty"` + SourceLocation *string // The name of the target build stage for the docker build. - Target *string `json:"target,omitempty"` + Target *string // Run timeout in seconds. - Timeout *int32 `json:"timeout,omitempty"` + Timeout *int32 } // GetRunRequest implements the RunRequestClassification interface for type DockerBuildRequest. @@ -682,34 +681,34 @@ func (d *DockerBuildRequest) GetRunRequest() *RunRequest { // DockerBuildStep - The Docker build step. type DockerBuildStep struct { // REQUIRED; The Docker file path relative to the source context. - DockerFilePath *string `json:"dockerFilePath,omitempty"` + DockerFilePath *string // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The collection of override arguments to be used when executing this build step. - Arguments []*Argument `json:"arguments,omitempty"` + Arguments []*Argument // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // The fully qualified image names including the repository and tag. - ImageNames []*string `json:"imageNames,omitempty"` + ImageNames []*string // The value of this property indicates whether the image built should be pushed to the registry or not. - IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + IsPushEnabled *bool // The value of this property indicates whether the image cache is enabled or not. - NoCache *bool `json:"noCache,omitempty"` + NoCache *bool // The name of the target build stage for the docker build. - Target *string `json:"target,omitempty"` + Target *string // READ-ONLY; List of base image dependencies for a step. - BaseImageDependencies []*BaseImageDependency `json:"baseImageDependencies,omitempty" azure:"ro"` + BaseImageDependencies []*BaseImageDependency } // GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type DockerBuildStep. @@ -725,31 +724,31 @@ func (d *DockerBuildStep) GetTaskStepProperties() *TaskStepProperties { // DockerBuildStepUpdateParameters - The properties for updating a docker build step. type DockerBuildStepUpdateParameters struct { // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The collection of override arguments to be used when executing this build step. - Arguments []*Argument `json:"arguments,omitempty"` + Arguments []*Argument // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // The Docker file path relative to the source context. - DockerFilePath *string `json:"dockerFilePath,omitempty"` + DockerFilePath *string // The fully qualified image names including the repository and tag. - ImageNames []*string `json:"imageNames,omitempty"` + ImageNames []*string // The value of this property indicates whether the image built should be pushed to the registry or not. - IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + IsPushEnabled *bool // The value of this property indicates whether the image cache is enabled or not. - NoCache *bool `json:"noCache,omitempty"` + NoCache *bool // The name of the target build stage for the docker build. - Target *string `json:"target,omitempty"` + Target *string } // GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type DockerBuildStepUpdateParameters. @@ -764,41 +763,41 @@ func (d *DockerBuildStepUpdateParameters) GetTaskStepUpdateParameters() *TaskSte // EncodedTaskRunRequest - The parameters for a quick task run request. type EncodedTaskRunRequest struct { // REQUIRED; Base64 encoded value of the template/definition file content. - EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + EncodedTaskContent *string // REQUIRED; The platform properties against which the run has to happen. - Platform *PlatformProperties `json:"platform,omitempty"` + Platform *PlatformProperties // REQUIRED; The type of the run request. - Type *string `json:"type,omitempty"` + Type *string // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The properties that describes a set of credentials that will be used when this run is invoked. - Credentials *Credentials `json:"credentials,omitempty"` + Credentials *Credentials // Base64 encoded value of the parameters/values file content. - EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + EncodedValuesContent *string // The value that indicates whether archiving is enabled for the run or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, // the relative path should be obtained from calling listBuildSourceUploadUrl API. - SourceLocation *string `json:"sourceLocation,omitempty"` + SourceLocation *string // Run timeout in seconds. - Timeout *int32 `json:"timeout,omitempty"` + Timeout *int32 // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue } // GetRunRequest implements the RunRequestClassification interface for type EncodedTaskRunRequest. @@ -814,25 +813,25 @@ func (e *EncodedTaskRunRequest) GetRunRequest() *RunRequest { // EncodedTaskStep - The properties of a encoded task step. type EncodedTaskStep struct { // REQUIRED; Base64 encoded value of the template/definition file content. - EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + EncodedTaskContent *string // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // Base64 encoded value of the parameters/values file content. - EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + EncodedValuesContent *string // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue // READ-ONLY; List of base image dependencies for a step. - BaseImageDependencies []*BaseImageDependency `json:"baseImageDependencies,omitempty" azure:"ro"` + BaseImageDependencies []*BaseImageDependency } // GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type EncodedTaskStep. @@ -848,22 +847,22 @@ func (e *EncodedTaskStep) GetTaskStepProperties() *TaskStepProperties { // EncodedTaskStepUpdateParameters - The properties for updating encoded task step. type EncodedTaskStepUpdateParameters struct { // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // Base64 encoded value of the template/definition file content. - EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + EncodedTaskContent *string // Base64 encoded value of the parameters/values file content. - EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + EncodedValuesContent *string // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue } // GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type EncodedTaskStepUpdateParameters. @@ -877,179 +876,179 @@ func (e *EncodedTaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskSte type EncryptionProperty struct { // Key vault properties. - KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + KeyVaultProperties *KeyVaultProperties // Indicates whether or not the encryption is enabled for container registry. - Status *EncryptionStatus `json:"status,omitempty"` + Status *EncryptionStatus } // ErrorResponse - An error response from the Azure Container Registry service. type ErrorResponse struct { // Azure container registry build API error body. - Error *ErrorResponseBody `json:"error,omitempty"` + Error *ErrorResponseBody } // ErrorResponseBody - An error response from the Azure Container Registry service. type ErrorResponseBody struct { // REQUIRED; error code. - Code *string `json:"code,omitempty"` + Code *string // REQUIRED; error message. - Message *string `json:"message,omitempty"` + Message *string // an array of additional nested error response info objects, as described by this contract. - Details []*InnerErrorDescription `json:"details,omitempty"` + Details []*InnerErrorDescription // target of the particular error. - Target *string `json:"target,omitempty"` + Target *string } // Event - The event for a webhook. type Event struct { // The event request message sent to the service URI. - EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` + EventRequestMessage *EventRequestMessage // The event response message received from the service URI. - EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` + EventResponseMessage *EventResponseMessage // The event ID. - ID *string `json:"id,omitempty"` + ID *string } // EventContent - The content of the event request message. type EventContent struct { // The action that encompasses the provided event. - Action *string `json:"action,omitempty"` + Action *string // The agent that initiated the event. For most situations, this could be from the authorization context of the request. - Actor *Actor `json:"actor,omitempty"` + Actor *Actor // The event ID. - ID *string `json:"id,omitempty"` + ID *string // The request that generated the event. - Request *Request `json:"request,omitempty"` + Request *Request // The registry node that generated the event. Put differently, while the actor initiates the event, the source generates // it. - Source *Source `json:"source,omitempty"` + Source *Source // The target of the event. - Target *Target `json:"target,omitempty"` + Target *Target // The time at which the event occurred. - Timestamp *time.Time `json:"timestamp,omitempty"` + Timestamp *time.Time } // EventInfo - The basic information of an event. type EventInfo struct { // The event ID. - ID *string `json:"id,omitempty"` + ID *string } // EventListResult - The result of a request to list events for a webhook. type EventListResult struct { // The URI that can be used to request the next list of events. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. - Value []*Event `json:"value,omitempty"` + Value []*Event } // EventRequestMessage - The event request message sent to the service URI. type EventRequestMessage struct { // The content of the event request message. - Content *EventContent `json:"content,omitempty"` + Content *EventContent // The headers of the event request message. - Headers map[string]*string `json:"headers,omitempty"` + Headers map[string]*string // The HTTP method used to send the event request message. - Method *string `json:"method,omitempty"` + Method *string // The URI used to send the event request message. - RequestURI *string `json:"requestUri,omitempty"` + RequestURI *string // The HTTP message version. - Version *string `json:"version,omitempty"` + Version *string } // EventResponseMessage - The event response message received from the service URI. type EventResponseMessage struct { // The content of the event response message. - Content *string `json:"content,omitempty"` + Content *string // The headers of the event response message. - Headers map[string]*string `json:"headers,omitempty"` + Headers map[string]*string // The reason phrase of the event response message. - ReasonPhrase *string `json:"reasonPhrase,omitempty"` + ReasonPhrase *string // The status code of the event response message. - StatusCode *string `json:"statusCode,omitempty"` + StatusCode *string // The HTTP message version. - Version *string `json:"version,omitempty"` + Version *string } // ExportPipeline - An object that represents an export pipeline for a container registry. type ExportPipeline struct { // The identity of the export pipeline. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The location of the export pipeline. - Location *string `json:"location,omitempty"` + Location *string // The properties of the export pipeline. - Properties *ExportPipelineProperties `json:"properties,omitempty"` + Properties *ExportPipelineProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ExportPipelineListResult - The result of a request to list export pipelines for a container registry. type ExportPipelineListResult struct { // The URI that can be used to request the next list of pipeline runs. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of export pipelines. Since this list may be incomplete, the nextLink field should be used to request the next // list of export pipelines. - Value []*ExportPipeline `json:"value,omitempty"` + Value []*ExportPipeline } // ExportPipelineProperties - The properties of an export pipeline. type ExportPipelineProperties struct { // REQUIRED; The target properties of the export pipeline. - Target *ExportPipelineTargetProperties `json:"target,omitempty"` + Target *ExportPipelineTargetProperties // The list of all options configured for the pipeline. - Options []*PipelineOptions `json:"options,omitempty"` + Options []*PipelineOptions // READ-ONLY; The provisioning state of the pipeline at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // ExportPipelineTargetProperties - The properties of the export pipeline target. type ExportPipelineTargetProperties struct { // REQUIRED; They key vault secret uri to obtain the target storage SAS token. - KeyVaultURI *string `json:"keyVaultUri,omitempty"` + KeyVaultURI *string // The type of target for the export pipeline. - Type *string `json:"type,omitempty"` + Type *string // The target uri of the export pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" // When 'AzureStorageBlobContainer': // "https://accountName.blob.core.windows.net/containerName" - URI *string `json:"uri,omitempty"` + URI *string } // ExportPipelinesClientBeginCreateOptions contains the optional parameters for the ExportPipelinesClient.BeginCreate method. @@ -1077,47 +1076,47 @@ type ExportPipelinesClientListOptions struct { // ExportPolicy - The export policy for a container registry. type ExportPolicy struct { // The value that indicates whether the policy is enabled or not. - Status *ExportPolicyStatus `json:"status,omitempty"` + Status *ExportPolicyStatus } // FileTaskRunRequest - The request parameters for a scheduling run against a task file. type FileTaskRunRequest struct { // REQUIRED; The platform properties against which the run has to happen. - Platform *PlatformProperties `json:"platform,omitempty"` + Platform *PlatformProperties // REQUIRED; The template/definition file path relative to the source. - TaskFilePath *string `json:"taskFilePath,omitempty"` + TaskFilePath *string // REQUIRED; The type of the run request. - Type *string `json:"type,omitempty"` + Type *string // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The properties that describes a set of credentials that will be used when this run is invoked. - Credentials *Credentials `json:"credentials,omitempty"` + Credentials *Credentials // The value that indicates whether archiving is enabled for the run or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, // the relative path should be obtained from calling listBuildSourceUploadUrl API. - SourceLocation *string `json:"sourceLocation,omitempty"` + SourceLocation *string // Run timeout in seconds. - Timeout *int32 `json:"timeout,omitempty"` + Timeout *int32 // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue // The values/parameters file path relative to the source. - ValuesFilePath *string `json:"valuesFilePath,omitempty"` + ValuesFilePath *string } // GetRunRequest implements the RunRequestClassification interface for type FileTaskRunRequest. @@ -1133,25 +1132,25 @@ func (f *FileTaskRunRequest) GetRunRequest() *RunRequest { // FileTaskStep - The properties of a task step. type FileTaskStep struct { // REQUIRED; The task template/definition file path relative to the source context. - TaskFilePath *string `json:"taskFilePath,omitempty"` + TaskFilePath *string // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue // The task values/parameters file path relative to the source context. - ValuesFilePath *string `json:"valuesFilePath,omitempty"` + ValuesFilePath *string // READ-ONLY; List of base image dependencies for a step. - BaseImageDependencies []*BaseImageDependency `json:"baseImageDependencies,omitempty" azure:"ro"` + BaseImageDependencies []*BaseImageDependency } // GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type FileTaskStep. @@ -1167,22 +1166,22 @@ func (f *FileTaskStep) GetTaskStepProperties() *TaskStepProperties { // FileTaskStepUpdateParameters - The properties of updating a task step. type FileTaskStepUpdateParameters struct { // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // The task template/definition file path relative to the source context. - TaskFilePath *string `json:"taskFilePath,omitempty"` + TaskFilePath *string // The collection of overridable values that can be passed when running a task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue // The values/parameters file path relative to the source context. - ValuesFilePath *string `json:"valuesFilePath,omitempty"` + ValuesFilePath *string } // GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type FileTaskStepUpdateParameters. @@ -1198,154 +1197,154 @@ func (f *FileTaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUp // registry. type GenerateCredentialsParameters struct { // The expiry date of the generated credentials after which the credentials become invalid. - Expiry *time.Time `json:"expiry,omitempty"` + Expiry *time.Time // Specifies name of the password which should be regenerated if any -- password1 or password2. - Name *TokenPasswordName `json:"name,omitempty"` + Name *TokenPasswordName // The resource ID of the token for which credentials have to be generated. - TokenID *string `json:"tokenId,omitempty"` + TokenID *string } // GenerateCredentialsResult - The response from the GenerateCredentials operation. type GenerateCredentialsResult struct { // The list of passwords for a container registry. - Passwords []*TokenPassword `json:"passwords,omitempty"` + Passwords []*TokenPassword // The username for a container registry. - Username *string `json:"username,omitempty"` + Username *string } // IPRule - IP rule with specific IP or IP range in CIDR format. type IPRule struct { // REQUIRED; Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. - IPAddressOrRange *string `json:"value,omitempty"` + IPAddressOrRange *string // The action of IP ACL rule. - Action *Action `json:"action,omitempty"` + Action *Action } // IdentityProperties - Managed identity for the resource. type IdentityProperties struct { // The principal ID of resource identity. - PrincipalID *string `json:"principalId,omitempty"` + PrincipalID *string // The tenant ID of resource. - TenantID *string `json:"tenantId,omitempty"` + TenantID *string // The identity type. - Type *ResourceIdentityType `json:"type,omitempty"` + Type *ResourceIdentityType // The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource // ids in the form: // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - UserAssignedIdentities map[string]*UserIdentityProperties `json:"userAssignedIdentities,omitempty"` + UserAssignedIdentities map[string]*UserIdentityProperties } // ImageDescriptor - Properties for a registry image. type ImageDescriptor struct { // The sha256-based digest of the image manifest. - Digest *string `json:"digest,omitempty"` + Digest *string // The registry login server. - Registry *string `json:"registry,omitempty"` + Registry *string // The repository name. - Repository *string `json:"repository,omitempty"` + Repository *string // The tag name. - Tag *string `json:"tag,omitempty"` + Tag *string } // ImageUpdateTrigger - The image update trigger that caused a build. type ImageUpdateTrigger struct { // The unique ID of the trigger. - ID *string `json:"id,omitempty"` + ID *string // The list of image updates that caused the build. - Images []*ImageDescriptor `json:"images,omitempty"` + Images []*ImageDescriptor // The timestamp when the image update happened. - Timestamp *time.Time `json:"timestamp,omitempty"` + Timestamp *time.Time } type ImportImageParameters struct { // REQUIRED; The source of the image. - Source *ImportSource `json:"source,omitempty"` + Source *ImportSource // When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation // before any copying begins. - Mode *ImportMode `json:"mode,omitempty"` + Mode *ImportMode // List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also // omitted). - TargetTags []*string `json:"targetTags,omitempty"` + TargetTags []*string // List of strings of repository names to do a manifest only copy. No tag will be created. - UntaggedTargetRepositories []*string `json:"untaggedTargetRepositories,omitempty"` + UntaggedTargetRepositories []*string } // ImportPipeline - An object that represents an import pipeline for a container registry. type ImportPipeline struct { // The identity of the import pipeline. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The location of the import pipeline. - Location *string `json:"location,omitempty"` + Location *string // The properties of the import pipeline. - Properties *ImportPipelineProperties `json:"properties,omitempty"` + Properties *ImportPipelineProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ImportPipelineListResult - The result of a request to list import pipelines for a container registry. type ImportPipelineListResult struct { // The URI that can be used to request the next list of pipeline runs. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of import pipelines. Since this list may be incomplete, the nextLink field should be used to request the next // list of import pipelines. - Value []*ImportPipeline `json:"value,omitempty"` + Value []*ImportPipeline } // ImportPipelineProperties - The properties of an import pipeline. type ImportPipelineProperties struct { // REQUIRED; The source properties of the import pipeline. - Source *ImportPipelineSourceProperties `json:"source,omitempty"` + Source *ImportPipelineSourceProperties // The list of all options configured for the pipeline. - Options []*PipelineOptions `json:"options,omitempty"` + Options []*PipelineOptions // The properties that describe the trigger of the import pipeline. - Trigger *PipelineTriggerProperties `json:"trigger,omitempty"` + Trigger *PipelineTriggerProperties // READ-ONLY; The provisioning state of the pipeline at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // ImportPipelineSourceProperties - The properties of the import pipeline source. type ImportPipelineSourceProperties struct { // REQUIRED; They key vault secret uri to obtain the source storage SAS token. - KeyVaultURI *string `json:"keyVaultUri,omitempty"` + KeyVaultURI *string // The type of source for the import pipeline. - Type *PipelineSourceType `json:"type,omitempty"` + Type *PipelineSourceType // The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" // When 'AzureStorageBlobContainer': // "https://accountName.blob.core.windows.net/containerName" - URI *string `json:"uri,omitempty"` + URI *string } // ImportPipelinesClientBeginCreateOptions contains the optional parameters for the ImportPipelinesClient.BeginCreate method. @@ -1374,171 +1373,171 @@ type ImportSource struct { // REQUIRED; Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' // tag. Specify an image by tag ('hello-world:latest'). Specify an image by sha256-based // manifest digest ('hello-world@sha256:abc123'). - SourceImage *string `json:"sourceImage,omitempty"` + SourceImage *string // Credentials used when importing from a registry uri. - Credentials *ImportSourceCredentials `json:"credentials,omitempty"` + Credentials *ImportSourceCredentials // The address of the source registry (e.g. 'mcr.microsoft.com'). - RegistryURI *string `json:"registryUri,omitempty"` + RegistryURI *string // The resource identifier of the source Azure Container Registry. - ResourceID *string `json:"resourceId,omitempty"` + ResourceID *string } type ImportSourceCredentials struct { // REQUIRED; The password used to authenticate with the source registry. - Password *string `json:"password,omitempty"` + Password *string // The username to authenticate with the source registry. - Username *string `json:"username,omitempty"` + Username *string } // InnerErrorDescription - inner error. type InnerErrorDescription struct { // REQUIRED; error code. - Code *string `json:"code,omitempty"` + Code *string // REQUIRED; error message. - Message *string `json:"message,omitempty"` + Message *string // target of the particular error. - Target *string `json:"target,omitempty"` + Target *string } type KeyVaultProperties struct { // The client id of the identity which will be used to access key vault. - Identity *string `json:"identity,omitempty"` + Identity *string // Key vault uri to access the encryption key. - KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyIdentifier *string // READ-ONLY; Auto key rotation status for a CMK enabled registry. - KeyRotationEnabled *bool `json:"keyRotationEnabled,omitempty" azure:"ro"` + KeyRotationEnabled *bool // READ-ONLY; Timestamp of the last successful key rotation. - LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` + LastKeyRotationTimestamp *time.Time // READ-ONLY; The fully qualified key identifier that includes the version of the key that is actually used for encryption. - VersionedKeyIdentifier *string `json:"versionedKeyIdentifier,omitempty" azure:"ro"` + VersionedKeyIdentifier *string } // LoggingProperties - The logging properties of the connected registry. type LoggingProperties struct { // Indicates whether audit logs are enabled on the connected registry. - AuditLogStatus *AuditLogStatus `json:"auditLogStatus,omitempty"` + AuditLogStatus *AuditLogStatus // The verbosity of logs persisted on the connected registry. - LogLevel *LogLevel `json:"logLevel,omitempty"` + LogLevel *LogLevel } // LoginServerProperties - The login server properties of the connected registry. type LoginServerProperties struct { // READ-ONLY; The host of the connected registry. Can be FQDN or IP. - Host *string `json:"host,omitempty" azure:"ro"` + Host *string // READ-ONLY; The TLS properties of the connected registry login server. - TLS *TLSProperties `json:"tls,omitempty" azure:"ro"` + TLS *TLSProperties } // NetworkRuleSet - The network rule set for a container registry. type NetworkRuleSet struct { // REQUIRED; The default action of allow or deny when no other rules match. - DefaultAction *DefaultAction `json:"defaultAction,omitempty"` + DefaultAction *DefaultAction // The IP ACL rules. - IPRules []*IPRule `json:"ipRules,omitempty"` + IPRules []*IPRule } // OperationDefinition - The definition of a container registry operation. type OperationDefinition struct { // The display information for the container registry operation. - Display *OperationDisplayDefinition `json:"display,omitempty"` + Display *OperationDisplayDefinition // This property indicates if the operation is an action or a data action ref: https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations - IsDataAction *bool `json:"isDataAction,omitempty"` + IsDataAction *bool // Operation name: {provider}/{resource}/{operation}. - Name *string `json:"name,omitempty"` + Name *string // The origin information of the container registry operation. - Origin *string `json:"origin,omitempty"` + Origin *string // The properties information for the container registry operation. - Properties *OperationPropertiesDefinition `json:"properties,omitempty"` + Properties *OperationPropertiesDefinition } // OperationDisplayDefinition - The display information for a container registry operation. type OperationDisplayDefinition struct { // The description for the operation. - Description *string `json:"description,omitempty"` + Description *string // The operation that users can perform. - Operation *string `json:"operation,omitempty"` + Operation *string // The resource provider name: Microsoft.ContainerRegistry. - Provider *string `json:"provider,omitempty"` + Provider *string // The resource on which the operation is performed. - Resource *string `json:"resource,omitempty"` + Resource *string } // OperationListResult - The result of a request to list container registry operations. type OperationListResult struct { // The URI that can be used to request the next list of container registry operations. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of container registry operations. Since this list may be incomplete, the nextLink field should be used to request // the next list of operations. - Value []*OperationDefinition `json:"value,omitempty"` + Value []*OperationDefinition } // OperationLogSpecificationDefinition - The definition of Azure Monitoring log. type OperationLogSpecificationDefinition struct { // Log blob duration. - BlobDuration *string `json:"blobDuration,omitempty"` + BlobDuration *string // Log display name. - DisplayName *string `json:"displayName,omitempty"` + DisplayName *string // Log name. - Name *string `json:"name,omitempty"` + Name *string } // OperationMetricSpecificationDefinition - The definition of Azure Monitoring metric. type OperationMetricSpecificationDefinition struct { // Metric aggregation type. - AggregationType *string `json:"aggregationType,omitempty"` + AggregationType *string // Metric description. - DisplayDescription *string `json:"displayDescription,omitempty"` + DisplayDescription *string // Metric display name. - DisplayName *string `json:"displayName,omitempty"` + DisplayName *string // Internal metric name. - InternalMetricName *string `json:"internalMetricName,omitempty"` + InternalMetricName *string // Metric name. - Name *string `json:"name,omitempty"` + Name *string // Metric unit. - Unit *string `json:"unit,omitempty"` + Unit *string } // OperationPropertiesDefinition - The definition of Azure Monitoring properties. type OperationPropertiesDefinition struct { // The definition of Azure Monitoring service. - ServiceSpecification *OperationServiceSpecificationDefinition `json:"serviceSpecification,omitempty"` + ServiceSpecification *OperationServiceSpecificationDefinition } // OperationServiceSpecificationDefinition - The definition of Azure Monitoring list. type OperationServiceSpecificationDefinition struct { // A list of Azure Monitoring log definitions. - LogSpecifications []*OperationLogSpecificationDefinition `json:"logSpecifications,omitempty"` + LogSpecifications []*OperationLogSpecificationDefinition // A list of Azure Monitoring metrics definition. - MetricSpecifications []*OperationMetricSpecificationDefinition `json:"metricSpecifications,omitempty"` + MetricSpecifications []*OperationMetricSpecificationDefinition } // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. @@ -1548,83 +1547,83 @@ type OperationsClientListOptions struct { type OverrideTaskStepProperties struct { // Gets or sets the collection of override arguments to be used when executing a build step. - Arguments []*Argument `json:"arguments,omitempty"` + Arguments []*Argument // The source context against which run has to be queued. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // The file against which run has to be queued. - File *string `json:"file,omitempty"` + File *string // The name of the target build stage for the docker build. - Target *string `json:"target,omitempty"` + Target *string // Base64 encoded update trigger token that will be attached with the base image trigger webhook. - UpdateTriggerToken *string `json:"updateTriggerToken,omitempty"` + UpdateTriggerToken *string // The collection of overridable values that can be passed when running a Task. - Values []*SetValue `json:"values,omitempty"` + Values []*SetValue } // PackageType - The properties of a package type. type PackageType struct { // The name of the package type. - Name *string `json:"name,omitempty"` + Name *string // READ-ONLY; The endpoint of the package type. - Endpoint *string `json:"endpoint,omitempty" azure:"ro"` + Endpoint *string } // ParentProperties - The properties of the connected registry parent. type ParentProperties struct { // REQUIRED; The sync properties of the connected registry with its parent. - SyncProperties *SyncProperties `json:"syncProperties,omitempty"` + SyncProperties *SyncProperties // The resource ID of the parent to which the connected registry will be associated. - ID *string `json:"id,omitempty"` + ID *string } // PipelineRun - An object that represents a pipeline run for a container registry. type PipelineRun struct { // The properties of a pipeline run. - Properties *PipelineRunProperties `json:"properties,omitempty"` + Properties *PipelineRunProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PipelineRunListResult - The result of a request to list pipeline runs for a container registry. type PipelineRunListResult struct { // The URI that can be used to request the next list of pipeline runs. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of pipeline runs. Since this list may be incomplete, the nextLink field should be used to request the next list // of pipeline runs. - Value []*PipelineRun `json:"value,omitempty"` + Value []*PipelineRun } // PipelineRunProperties - The properties of a pipeline run. type PipelineRunProperties struct { // How the pipeline run should be forced to recreate even if the pipeline run configuration has not changed. - ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + ForceUpdateTag *string // The request parameters for a pipeline run. - Request *PipelineRunRequest `json:"request,omitempty"` + Request *PipelineRunRequest // READ-ONLY; The provisioning state of a pipeline run. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The response of a pipeline run. - Response *PipelineRunResponse `json:"response,omitempty" azure:"ro"` + Response *PipelineRunResponse } // PipelineRunRequest - The request properties provided for a pipeline run. @@ -1632,68 +1631,68 @@ type PipelineRunRequest struct { // List of source artifacts to be transferred by the pipeline. Specify an image by repository ('hello-world'). This will use // the 'latest' tag. Specify an image by tag ('hello-world:latest'). Specify an // image by sha256-based manifest digest ('hello-world@sha256:abc123'). - Artifacts []*string `json:"artifacts,omitempty"` + Artifacts []*string // The digest of the tar used to transfer the artifacts. - CatalogDigest *string `json:"catalogDigest,omitempty"` + CatalogDigest *string // The resource ID of the pipeline to run. - PipelineResourceID *string `json:"pipelineResourceId,omitempty"` + PipelineResourceID *string // The source properties of the pipeline run. - Source *PipelineRunSourceProperties `json:"source,omitempty"` + Source *PipelineRunSourceProperties // The target properties of the pipeline run. - Target *PipelineRunTargetProperties `json:"target,omitempty"` + Target *PipelineRunTargetProperties } // PipelineRunResponse - The response properties returned for a pipeline run. type PipelineRunResponse struct { // The digest of the tar used to transfer the artifacts. - CatalogDigest *string `json:"catalogDigest,omitempty"` + CatalogDigest *string // The time the pipeline run finished. - FinishTime *time.Time `json:"finishTime,omitempty"` + FinishTime *time.Time // The artifacts imported in the pipeline run. - ImportedArtifacts []*string `json:"importedArtifacts,omitempty"` + ImportedArtifacts []*string // The detailed error message for the pipeline run in the case of failure. - PipelineRunErrorMessage *string `json:"pipelineRunErrorMessage,omitempty"` + PipelineRunErrorMessage *string // The current progress of the copy operation. - Progress *ProgressProperties `json:"progress,omitempty"` + Progress *ProgressProperties // The source of the pipeline run. - Source *ImportPipelineSourceProperties `json:"source,omitempty"` + Source *ImportPipelineSourceProperties // The time the pipeline run started. - StartTime *time.Time `json:"startTime,omitempty"` + StartTime *time.Time // The current status of the pipeline run. - Status *string `json:"status,omitempty"` + Status *string // The target of the pipeline run. - Target *ExportPipelineTargetProperties `json:"target,omitempty"` + Target *ExportPipelineTargetProperties // The trigger that caused the pipeline run. - Trigger *PipelineTriggerDescriptor `json:"trigger,omitempty"` + Trigger *PipelineTriggerDescriptor } type PipelineRunSourceProperties struct { // The name of the source. - Name *string `json:"name,omitempty"` + Name *string // The type of the source. - Type *PipelineRunSourceType `json:"type,omitempty"` + Type *PipelineRunSourceType } type PipelineRunTargetProperties struct { // The name of the target. - Name *string `json:"name,omitempty"` + Name *string // The type of the target. - Type *PipelineRunTargetType `json:"type,omitempty"` + Type *PipelineRunTargetType } // PipelineRunsClientBeginCreateOptions contains the optional parameters for the PipelineRunsClient.BeginCreate method. @@ -1720,113 +1719,113 @@ type PipelineRunsClientListOptions struct { type PipelineSourceTriggerDescriptor struct { // The timestamp when the source update happened. - Timestamp *time.Time `json:"timestamp,omitempty"` + Timestamp *time.Time } type PipelineSourceTriggerProperties struct { // REQUIRED; The current status of the source trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus } type PipelineTriggerDescriptor struct { // The source trigger that caused the pipeline run. - SourceTrigger *PipelineSourceTriggerDescriptor `json:"sourceTrigger,omitempty"` + SourceTrigger *PipelineSourceTriggerDescriptor } type PipelineTriggerProperties struct { // The source trigger properties of the pipeline. - SourceTrigger *PipelineSourceTriggerProperties `json:"sourceTrigger,omitempty"` + SourceTrigger *PipelineSourceTriggerProperties } // PlatformProperties - The platform properties against which the run has to happen. type PlatformProperties struct { // REQUIRED; The operating system type required for the run. - OS *OS `json:"os,omitempty"` + OS *OS // The OS architecture. - Architecture *Architecture `json:"architecture,omitempty"` + Architecture *Architecture // Variant of the CPU. - Variant *Variant `json:"variant,omitempty"` + Variant *Variant } // PlatformUpdateParameters - The properties for updating the platform configuration. type PlatformUpdateParameters struct { // The OS architecture. - Architecture *Architecture `json:"architecture,omitempty"` + Architecture *Architecture // The operating system type required for the run. - OS *OS `json:"os,omitempty"` + OS *OS // Variant of the CPU. - Variant *Variant `json:"variant,omitempty"` + Variant *Variant } // Policies - The policies for a container registry. type Policies struct { // The policy for using ARM audience token for a container registry. - AzureADAuthenticationAsArmPolicy *AzureADAuthenticationAsArmPolicy `json:"azureADAuthenticationAsArmPolicy,omitempty"` + AzureADAuthenticationAsArmPolicy *AzureADAuthenticationAsArmPolicy // The export policy for a container registry. - ExportPolicy *ExportPolicy `json:"exportPolicy,omitempty"` + ExportPolicy *ExportPolicy // The quarantine policy for a container registry. - QuarantinePolicy *QuarantinePolicy `json:"quarantinePolicy,omitempty"` + QuarantinePolicy *QuarantinePolicy // The retention policy for a container registry. - RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + RetentionPolicy *RetentionPolicy // The soft delete policy for a container registry. - SoftDeletePolicy *SoftDeletePolicy `json:"softDeletePolicy,omitempty"` + SoftDeletePolicy *SoftDeletePolicy // The content trust policy for a container registry. - TrustPolicy *TrustPolicy `json:"trustPolicy,omitempty"` + TrustPolicy *TrustPolicy } // PrivateEndpoint - The Private Endpoint resource. type PrivateEndpoint struct { // This is private endpoint resource created with Microsoft.Network resource provider. - ID *string `json:"id,omitempty"` + ID *string } // PrivateEndpointConnection - An object that represents a private endpoint connection for a container registry. type PrivateEndpointConnection struct { // The properties of a private endpoint connection. - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Properties *PrivateEndpointConnectionProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PrivateEndpointConnectionListResult - The result of a request to list private endpoint connections for a container registry. type PrivateEndpointConnectionListResult struct { // The URI that can be used to request the next list of private endpoint connections. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of private endpoint connections. Since this list may be incomplete, the nextLink field should be used to request // the next list of private endpoint connections. - Value []*PrivateEndpointConnection `json:"value,omitempty"` + Value []*PrivateEndpointConnection } // PrivateEndpointConnectionProperties - The properties of a private endpoint connection. type PrivateEndpointConnectionProperties struct { // The resource of private endpoint. - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpoint *PrivateEndpoint // A collection of information about the state of the connection between service consumer and provider. - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState // READ-ONLY; The provisioning state of private endpoint connection resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginCreateOrUpdate @@ -1858,83 +1857,83 @@ type PrivateEndpointConnectionsClientListOptions struct { // PrivateLinkResource - A resource that supports private link capabilities. type PrivateLinkResource struct { // The resource ID. - ID *string `json:"id,omitempty"` + ID *string // The name of the resource. - Name *string `json:"name,omitempty"` + Name *string // A resource that supports private link capabilities. - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Properties *PrivateLinkResourceProperties // READ-ONLY; The resource type is private link resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PrivateLinkResourceListResult - The result of a request to list private link resources for a container registry. type PrivateLinkResourceListResult struct { // The URI that can be used to request the next list of private link resources. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of private link resources. Since this list may be incomplete, the nextLink field should be used to request the // next list of private link resources. - Value []*PrivateLinkResource `json:"value,omitempty"` + Value []*PrivateLinkResource } // PrivateLinkResourceProperties - The properties of a private link resource. type PrivateLinkResourceProperties struct { // The private link resource group id. - GroupID *string `json:"groupId,omitempty"` + GroupID *string // The private link resource required member names. - RequiredMembers []*string `json:"requiredMembers,omitempty"` + RequiredMembers []*string // The private link resource Private link DNS zone name. - RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` + RequiredZoneNames []*string } // PrivateLinkServiceConnectionState - The state of a private link service connection. type PrivateLinkServiceConnectionState struct { // A message indicating if changes on the service provider require any updates on the consumer. - ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` + ActionsRequired *ActionsRequired // The description for connection status. For example if connection is rejected it can indicate reason for rejection. - Description *string `json:"description,omitempty"` + Description *string // The private link service connection status. - Status *ConnectionStatus `json:"status,omitempty"` + Status *ConnectionStatus } type ProgressProperties struct { // The percentage complete of the copy operation. - Percentage *string `json:"percentage,omitempty"` + Percentage *string } // ProxyResource - The resource model definition for a ARM proxy resource. It will have everything other than required location // and tags. type ProxyResource struct { // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // QuarantinePolicy - The quarantine policy for a container registry. type QuarantinePolicy struct { // The value that indicates whether the policy is enabled or not. - Status *PolicyStatus `json:"status,omitempty"` + Status *PolicyStatus } // RegenerateCredentialParameters - The parameters used to regenerate the login credential. type RegenerateCredentialParameters struct { // REQUIRED; Specifies name of the password which should be regenerated -- password or password2. - Name *PasswordName `json:"name,omitempty"` + Name *PasswordName } // RegistriesClientBeginCreateOptions contains the optional parameters for the RegistriesClient.BeginCreate method. @@ -2033,226 +2032,226 @@ type RegistriesClientRegenerateCredentialOptions struct { // Registry - An object that represents a container registry. type Registry struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // REQUIRED; The SKU of the container registry. - SKU *SKU `json:"sku,omitempty"` + SKU *SKU // The identity of the container registry. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties of the container registry. - Properties *RegistryProperties `json:"properties,omitempty"` + Properties *RegistryProperties // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // RegistryListCredentialsResult - The response from the ListCredentials operation. type RegistryListCredentialsResult struct { // The list of passwords for a container registry. - Passwords []*RegistryPassword `json:"passwords,omitempty"` + Passwords []*RegistryPassword // The username for a container registry. - Username *string `json:"username,omitempty"` + Username *string } // RegistryListResult - The result of a request to list container registries. type RegistryListResult struct { // The URI that can be used to request the next list of container registries. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next // list of container registries. - Value []*Registry `json:"value,omitempty"` + Value []*Registry } // RegistryNameCheckRequest - A request to check whether a container registry name is available. type RegistryNameCheckRequest struct { // REQUIRED; The name of the container registry. - Name *string `json:"name,omitempty"` + Name *string // CONSTANT; The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. // Field has constant value "Microsoft.ContainerRegistry/registries", any specified value is ignored. - Type *string `json:"type,omitempty"` + Type *string } // RegistryNameStatus - The result of a request to check the availability of a container registry name. type RegistryNameStatus struct { // If any, the error message that provides more detail for the reason that the name is not available. - Message *string `json:"message,omitempty"` + Message *string // The value that indicates whether the name is available. - NameAvailable *bool `json:"nameAvailable,omitempty"` + NameAvailable *bool // If any, the reason that the name is not available. - Reason *string `json:"reason,omitempty"` + Reason *string } // RegistryPassword - The login password for the container registry. type RegistryPassword struct { // The password name. - Name *PasswordName `json:"name,omitempty"` + Name *PasswordName // The password value. - Value *string `json:"value,omitempty"` + Value *string } // RegistryProperties - The properties of a container registry. type RegistryProperties struct { // The value that indicates whether the admin user is enabled. - AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + AdminUserEnabled *bool // Enables registry-wide pull from unauthenticated clients. - AnonymousPullEnabled *bool `json:"anonymousPullEnabled,omitempty"` + AnonymousPullEnabled *bool // Enable a single data endpoint per region for serving data. - DataEndpointEnabled *bool `json:"dataEndpointEnabled,omitempty"` + DataEndpointEnabled *bool // The encryption settings of container registry. - Encryption *EncryptionProperty `json:"encryption,omitempty"` + Encryption *EncryptionProperty // Whether to allow trusted Azure services to access a network restricted registry. - NetworkRuleBypassOptions *NetworkRuleBypassOptions `json:"networkRuleBypassOptions,omitempty"` + NetworkRuleBypassOptions *NetworkRuleBypassOptions // The network rule set for a container registry. - NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + NetworkRuleSet *NetworkRuleSet // The policies for a container registry. - Policies *Policies `json:"policies,omitempty"` + Policies *Policies // Whether or not public network access is allowed for the container registry. - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicNetworkAccess *PublicNetworkAccess // Whether or not zone redundancy is enabled for this container registry - ZoneRedundancy *ZoneRedundancy `json:"zoneRedundancy,omitempty"` + ZoneRedundancy *ZoneRedundancy // READ-ONLY; The creation date of the container registry in ISO8601 format. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; List of host names that will serve data when dataEndpointEnabled is true. - DataEndpointHostNames []*string `json:"dataEndpointHostNames,omitempty" azure:"ro"` + DataEndpointHostNames []*string // READ-ONLY; The URL that can be used to log into the container registry. - LoginServer *string `json:"loginServer,omitempty" azure:"ro"` + LoginServer *string // READ-ONLY; List of private endpoint connections for a container registry. - PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + PrivateEndpointConnections []*PrivateEndpointConnection // READ-ONLY; The provisioning state of the container registry at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The status of the container registry at the time the operation was called. - Status *Status `json:"status,omitempty" azure:"ro"` + Status *Status } // RegistryPropertiesUpdateParameters - The parameters for updating the properties of a container registry. type RegistryPropertiesUpdateParameters struct { // The value that indicates whether the admin user is enabled. - AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + AdminUserEnabled *bool // Enables registry-wide pull from unauthenticated clients. - AnonymousPullEnabled *bool `json:"anonymousPullEnabled,omitempty"` + AnonymousPullEnabled *bool // Enable a single data endpoint per region for serving data. - DataEndpointEnabled *bool `json:"dataEndpointEnabled,omitempty"` + DataEndpointEnabled *bool // The encryption settings of container registry. - Encryption *EncryptionProperty `json:"encryption,omitempty"` + Encryption *EncryptionProperty // Whether to allow trusted Azure services to access a network restricted registry. - NetworkRuleBypassOptions *NetworkRuleBypassOptions `json:"networkRuleBypassOptions,omitempty"` + NetworkRuleBypassOptions *NetworkRuleBypassOptions // The network rule set for a container registry. - NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + NetworkRuleSet *NetworkRuleSet // The policies for a container registry. - Policies *Policies `json:"policies,omitempty"` + Policies *Policies // Whether or not public network access is allowed for the container registry. - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicNetworkAccess *PublicNetworkAccess } // RegistryUpdateParameters - The parameters for updating a container registry. type RegistryUpdateParameters struct { // The identity of the container registry. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties that the container registry will be updated with. - Properties *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *RegistryPropertiesUpdateParameters // The SKU of the container registry. - SKU *SKU `json:"sku,omitempty"` + SKU *SKU // The tags for the container registry. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // RegistryUsage - The quota usage for a container registry. type RegistryUsage struct { // The current value of the usage. - CurrentValue *int64 `json:"currentValue,omitempty"` + CurrentValue *int64 // The limit of the usage. - Limit *int64 `json:"limit,omitempty"` + Limit *int64 // The name of the usage. - Name *string `json:"name,omitempty"` + Name *string // The unit of measurement. - Unit *RegistryUsageUnit `json:"unit,omitempty"` + Unit *RegistryUsageUnit } // RegistryUsageListResult - The result of a request to get container registry quota usages. type RegistryUsageListResult struct { // The list of container registry quota usages. - Value []*RegistryUsage `json:"value,omitempty"` + Value []*RegistryUsage } // Replication - An object that represents a replication for a container registry. type Replication struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // The properties of the replication. - Properties *ReplicationProperties `json:"properties,omitempty"` + Properties *ReplicationProperties // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ReplicationListResult - The result of a request to list replications for a container registry. type ReplicationListResult struct { // The URI that can be used to request the next list of replications. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of replications. Since this list may be incomplete, the nextLink field should be used to request the next list // of replications. - Value []*Replication `json:"value,omitempty"` + Value []*Replication } // ReplicationProperties - The properties of a replication. @@ -2260,32 +2259,32 @@ type ReplicationProperties struct { // Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional // endpoint is disabled, however its data will continue to be synced with // other replications. - RegionEndpointEnabled *bool `json:"regionEndpointEnabled,omitempty"` + RegionEndpointEnabled *bool // Whether or not zone redundancy is enabled for this container registry replication - ZoneRedundancy *ZoneRedundancy `json:"zoneRedundancy,omitempty"` + ZoneRedundancy *ZoneRedundancy // READ-ONLY; The provisioning state of the replication at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The status of the replication at the time the operation was called. - Status *Status `json:"status,omitempty" azure:"ro"` + Status *Status } // ReplicationUpdateParameters - The parameters for updating a replication. type ReplicationUpdateParameters struct { // The parameters for updating a replication's properties - Properties *ReplicationUpdateParametersProperties `json:"properties,omitempty"` + Properties *ReplicationUpdateParametersProperties // The tags for the replication. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } type ReplicationUpdateParametersProperties struct { // Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional // endpoint is disabled, however its data will continue to be synced with // other replications. - RegionEndpointEnabled *bool `json:"regionEndpointEnabled,omitempty"` + RegionEndpointEnabled *bool } // ReplicationsClientBeginCreateOptions contains the optional parameters for the ReplicationsClient.BeginCreate method. @@ -2320,188 +2319,188 @@ type ReplicationsClientListOptions struct { type Request struct { // The IP or hostname and possibly port of the client connection that initiated the event. This is the RemoteAddr from the // standard http request. - Addr *string `json:"addr,omitempty"` + Addr *string // The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. - Host *string `json:"host,omitempty"` + Host *string // The ID of the request that initiated the event. - ID *string `json:"id,omitempty"` + ID *string // The request method that generated the event. - Method *string `json:"method,omitempty"` + Method *string // The user agent header of the request. - Useragent *string `json:"useragent,omitempty"` + Useragent *string } // Resource - An Azure resource. type Resource struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // RetentionPolicy - The retention policy for a container registry. type RetentionPolicy struct { // The number of days to retain an untagged manifest after which it gets purged. - Days *int32 `json:"days,omitempty"` + Days *int32 // The value that indicates whether the policy is enabled or not. - Status *PolicyStatus `json:"status,omitempty"` + Status *PolicyStatus // READ-ONLY; The timestamp when the policy was last updated. - LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` + LastUpdatedTime *time.Time } // Run resource properties type Run struct { // The properties of a run. - Properties *RunProperties `json:"properties,omitempty"` + Properties *RunProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // RunFilter - Properties that are enabled for Odata querying on runs. type RunFilter struct { // The name of the agent pool that the run corresponds to. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The create time for a run. - CreateTime *time.Time `json:"createTime,omitempty"` + CreateTime *time.Time // The time the run finished. - FinishTime *time.Time `json:"finishTime,omitempty"` + FinishTime *time.Time // The value that indicates whether archiving is enabled or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The list of comma-separated image manifests that were generated from the run. This is applicable if the run is of build // type. - OutputImageManifests *string `json:"outputImageManifests,omitempty"` + OutputImageManifests *string // The unique identifier for the run. - RunID *string `json:"runId,omitempty"` + RunID *string // The type of run. - RunType *RunType `json:"runType,omitempty"` + RunType *RunType // The current status of the run. - Status *RunStatus `json:"status,omitempty"` + Status *RunStatus // The name of the task that the run corresponds to. - TaskName *string `json:"taskName,omitempty"` + TaskName *string } // RunGetLogResult - The result of get log link operation. type RunGetLogResult struct { // The link to logs in registry for a run on a azure container registry. - LogArtifactLink *string `json:"logArtifactLink,omitempty"` + LogArtifactLink *string // The link to logs for a run on a azure container registry. - LogLink *string `json:"logLink,omitempty"` + LogLink *string } // RunListResult - Collection of runs. type RunListResult struct { // The URI that can be used to request the next set of paged results. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The collection value. - Value []*Run `json:"value,omitempty"` + Value []*Run } // RunProperties - The properties for a run. type RunProperties struct { // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The time the run was scheduled. - CreateTime *time.Time `json:"createTime,omitempty"` + CreateTime *time.Time // The list of custom registries that were logged in during this run. - CustomRegistries []*string `json:"customRegistries,omitempty"` + CustomRegistries []*string // The time the run finished. - FinishTime *time.Time `json:"finishTime,omitempty"` + FinishTime *time.Time // The image update trigger that caused the run. This is applicable if the task has base image trigger configured. - ImageUpdateTrigger *ImageUpdateTrigger `json:"imageUpdateTrigger,omitempty"` + ImageUpdateTrigger *ImageUpdateTrigger // The value that indicates whether archiving is enabled or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The last updated time for the run. - LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty"` + LastUpdatedTime *time.Time // The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. - OutputImages []*ImageDescriptor `json:"outputImages,omitempty"` + OutputImages []*ImageDescriptor // The platform properties against which the run will happen. - Platform *PlatformProperties `json:"platform,omitempty"` + Platform *PlatformProperties // The provisioning state of a run. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ProvisioningState *ProvisioningState // The unique identifier for the run. - RunID *string `json:"runId,omitempty"` + RunID *string // The type of run. - RunType *RunType `json:"runType,omitempty"` + RunType *RunType // The scope of the credentials that were used to login to the source registry during this run. - SourceRegistryAuth *string `json:"sourceRegistryAuth,omitempty"` + SourceRegistryAuth *string // The source trigger that caused the run. - SourceTrigger *SourceTriggerDescriptor `json:"sourceTrigger,omitempty"` + SourceTrigger *SourceTriggerDescriptor // The time the run started. - StartTime *time.Time `json:"startTime,omitempty"` + StartTime *time.Time // The current status of the run. - Status *RunStatus `json:"status,omitempty"` + Status *RunStatus // The task against which run was scheduled. - Task *string `json:"task,omitempty"` + Task *string // The timer trigger that caused the run. - TimerTrigger *TimerTriggerDescriptor `json:"timerTrigger,omitempty"` + TimerTrigger *TimerTriggerDescriptor // The update trigger token passed for the Run. - UpdateTriggerToken *string `json:"updateTriggerToken,omitempty"` + UpdateTriggerToken *string // READ-ONLY; The image description for the log artifact. - LogArtifact *ImageDescriptor `json:"logArtifact,omitempty" azure:"ro"` + LogArtifact *ImageDescriptor // READ-ONLY; The error message received from backend systems after the run is scheduled. - RunErrorMessage *string `json:"runErrorMessage,omitempty" azure:"ro"` + RunErrorMessage *string } // RunRequestClassification provides polymorphic access to related types. @@ -2516,16 +2515,16 @@ type RunRequestClassification interface { // RunRequest - The request parameters for scheduling a run. type RunRequest struct { // REQUIRED; The type of the run request. - Type *string `json:"type,omitempty"` + Type *string // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The value that indicates whether archiving is enabled for the run or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string } // GetRunRequest implements the RunRequestClassification interface for type RunRequest. @@ -2534,7 +2533,7 @@ func (r *RunRequest) GetRunRequest() *RunRequest { return r } // RunUpdateParameters - The set of run properties that can be updated. type RunUpdateParameters struct { // The value that indicates whether archiving is enabled or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool } // RunsClientBeginCancelOptions contains the optional parameters for the RunsClient.BeginCancel method. @@ -2571,71 +2570,71 @@ type RunsClientListOptions struct { // SKU - The SKU of a container registry. type SKU struct { // REQUIRED; The SKU name of the container registry. Required for registry creation. - Name *SKUName `json:"name,omitempty"` + Name *SKUName // READ-ONLY; The SKU tier based on the SKU name. - Tier *SKUTier `json:"tier,omitempty" azure:"ro"` + Tier *SKUTier } // ScopeMap - An object that represents a scope map for a container registry. type ScopeMap struct { // The properties of the scope map. - Properties *ScopeMapProperties `json:"properties,omitempty"` + Properties *ScopeMapProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ScopeMapListResult - The result of a request to list scope maps for a container registry. type ScopeMapListResult struct { // The URI that can be used to request the next list of scope maps. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of // scope maps. - Value []*ScopeMap `json:"value,omitempty"` + Value []*ScopeMap } // ScopeMapProperties - The properties of a scope map. type ScopeMapProperties struct { // REQUIRED; The list of scoped permissions for registry artifacts. E.g. repositories/repository-name/content/read, repositories/repository-name/metadata/write - Actions []*string `json:"actions,omitempty"` + Actions []*string // The user friendly description of the scope map. - Description *string `json:"description,omitempty"` + Description *string // READ-ONLY; The creation date of scope map. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; Provisioning state of the resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The type of the scope map. E.g. BuildIn scope map. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ScopeMapPropertiesUpdateParameters - The update parameters for scope map properties. type ScopeMapPropertiesUpdateParameters struct { // The list of scope permissions for registry artifacts. E.g. repositories/repository-name/pull, repositories/repository-name/delete - Actions []*string `json:"actions,omitempty"` + Actions []*string // The user friendly description of the scope map. - Description *string `json:"description,omitempty"` + Description *string } // ScopeMapUpdateParameters - The properties for updating the scope map. type ScopeMapUpdateParameters struct { // The update parameters for scope map properties. - Properties *ScopeMapPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *ScopeMapPropertiesUpdateParameters } // ScopeMapsClientBeginCreateOptions contains the optional parameters for the ScopeMapsClient.BeginCreate method. @@ -2669,35 +2668,35 @@ type ScopeMapsClientListOptions struct { // SecretObject - Describes the properties of a secret object value. type SecretObject struct { // The type of the secret object which determines how the value of the secret object has to be interpreted. - Type *SecretObjectType `json:"type,omitempty"` + Type *SecretObjectType // The value of the secret. The format of this value will be determined based on the type of the secret object. If the type // is Opaque, the value will be used as is without any modification. - Value *string `json:"value,omitempty"` + Value *string } // SetValue - The properties of a overridable value that can be passed to a task template. type SetValue struct { // REQUIRED; The name of the overridable value. - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; The overridable value. - Value *string `json:"value,omitempty"` + Value *string // Flag to indicate whether the value represents a secret or not. - IsSecret *bool `json:"isSecret,omitempty"` + IsSecret *bool } // SoftDeletePolicy - The soft delete policy for a container registry type SoftDeletePolicy struct { // The number of days after which a soft-deleted item is permanently deleted. - RetentionDays *int32 `json:"retentionDays,omitempty"` + RetentionDays *int32 // The value that indicates whether the policy is enabled or not. - Status *PolicyStatus `json:"status,omitempty"` + Status *PolicyStatus // READ-ONLY; The timestamp when the policy was last updated. - LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` + LastUpdatedTime *time.Time } // Source - The registry node that generated the event. Put differently, while the actor initiates the event, the source generates @@ -2705,25 +2704,25 @@ type SoftDeletePolicy struct { type Source struct { // The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() // along with the running port. - Addr *string `json:"addr,omitempty"` + Addr *string // The running instance of an application. Changes after each restart. - InstanceID *string `json:"instanceID,omitempty"` + InstanceID *string } // SourceProperties - The properties of the source code repository. type SourceProperties struct { // REQUIRED; The full URL to the source code repository - RepositoryURL *string `json:"repositoryUrl,omitempty"` + RepositoryURL *string // REQUIRED; The type of source control service. - SourceControlType *SourceControlType `json:"sourceControlType,omitempty"` + SourceControlType *SourceControlType // The branch name of the source code. - Branch *string `json:"branch,omitempty"` + Branch *string // The authorization properties for accessing the source code repository and to set up webhooks for notifications. - SourceControlAuthProperties *AuthInfo `json:"sourceControlAuthProperties,omitempty"` + SourceControlAuthProperties *AuthInfo } // SourceRegistryCredentials - Describes the credential parameters for accessing the source registry. @@ -2731,412 +2730,412 @@ type SourceRegistryCredentials struct { // The authentication mode which determines the source registry login scope. The credentials for the source registry will // be generated using the given scope. These credentials will be used to login to // the source registry during the run. - LoginMode *SourceRegistryLoginMode `json:"loginMode,omitempty"` + LoginMode *SourceRegistryLoginMode } // SourceTrigger - The properties of a source based trigger. type SourceTrigger struct { // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; The properties that describes the source(code) for the task. - SourceRepository *SourceProperties `json:"sourceRepository,omitempty"` + SourceRepository *SourceProperties // REQUIRED; The source event corresponding to the trigger. - SourceTriggerEvents []*SourceTriggerEvent `json:"sourceTriggerEvents,omitempty"` + SourceTriggerEvents []*SourceTriggerEvent // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus } // SourceTriggerDescriptor - The source trigger that caused a run. type SourceTriggerDescriptor struct { // The branch name in the repository. - BranchName *string `json:"branchName,omitempty"` + BranchName *string // The unique ID that identifies a commit. - CommitID *string `json:"commitId,omitempty"` + CommitID *string // The event type of the trigger. - EventType *string `json:"eventType,omitempty"` + EventType *string // The unique ID of the trigger. - ID *string `json:"id,omitempty"` + ID *string // The source control provider type. - ProviderType *string `json:"providerType,omitempty"` + ProviderType *string // The unique ID that identifies pull request. - PullRequestID *string `json:"pullRequestId,omitempty"` + PullRequestID *string // The repository URL. - RepositoryURL *string `json:"repositoryUrl,omitempty"` + RepositoryURL *string } // SourceTriggerUpdateParameters - The properties for updating a source based trigger. type SourceTriggerUpdateParameters struct { // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // The properties that describes the source(code) for the task. - SourceRepository *SourceUpdateParameters `json:"sourceRepository,omitempty"` + SourceRepository *SourceUpdateParameters // The source event corresponding to the trigger. - SourceTriggerEvents []*SourceTriggerEvent `json:"sourceTriggerEvents,omitempty"` + SourceTriggerEvents []*SourceTriggerEvent // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus } // SourceUpdateParameters - The properties for updating the source code repository. type SourceUpdateParameters struct { // The branch name of the source code. - Branch *string `json:"branch,omitempty"` + Branch *string // The full URL to the source code repository - RepositoryURL *string `json:"repositoryUrl,omitempty"` + RepositoryURL *string // The authorization properties for accessing the source code repository and to set up webhooks for notifications. - SourceControlAuthProperties *AuthInfoUpdateParameters `json:"sourceControlAuthProperties,omitempty"` + SourceControlAuthProperties *AuthInfoUpdateParameters // The type of source control service. - SourceControlType *SourceControlType `json:"sourceControlType,omitempty"` + SourceControlType *SourceControlType } // SourceUploadDefinition - The properties of a response to source upload request. type SourceUploadDefinition struct { // The relative path to the source. This is used to submit the subsequent queue build request. - RelativePath *string `json:"relativePath,omitempty"` + RelativePath *string // The URL where the client can upload the source. - UploadURL *string `json:"uploadUrl,omitempty"` + UploadURL *string } // Status - The status of an Azure resource at the time the operation was called. type Status struct { // READ-ONLY; The short label for the status. - DisplayStatus *string `json:"displayStatus,omitempty" azure:"ro"` + DisplayStatus *string // READ-ONLY; The detailed message for the status, including alerts and error messages. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; The timestamp when the status was changed to the current value. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + Timestamp *time.Time } // StatusDetailProperties - The status detail properties of the connected registry. type StatusDetailProperties struct { // READ-ONLY; The code of the status. - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; The correlation ID of the status. - CorrelationID *string `json:"correlationId,omitempty" azure:"ro"` + CorrelationID *string // READ-ONLY; The description of the status. - Description *string `json:"description,omitempty" azure:"ro"` + Description *string // READ-ONLY; The timestamp of the status. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + Timestamp *time.Time // READ-ONLY; The component of the connected registry corresponding to the status. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // StorageAccountProperties - The properties of a storage account for a container registry. Only applicable to Classic SKU. type StorageAccountProperties struct { // REQUIRED; The resource ID of the storage account. - ID *string `json:"id,omitempty"` + ID *string } // SyncProperties - The sync properties of the connected registry with its parent. type SyncProperties struct { // REQUIRED; The period of time for which a message is available to sync before it is expired. Specify the duration using // the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. - MessageTTL *string `json:"messageTtl,omitempty"` + MessageTTL *string // REQUIRED; The resource ID of the ACR token used to authenticate the connected registry to its parent during sync. - TokenID *string `json:"tokenId,omitempty"` + TokenID *string // The cron expression indicating the schedule that the connected registry will sync with its parent. - Schedule *string `json:"schedule,omitempty"` + Schedule *string // The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S // as per ISO8601. - SyncWindow *string `json:"syncWindow,omitempty"` + SyncWindow *string // READ-ONLY; The gateway endpoint used by the connected registry to communicate with its parent. - GatewayEndpoint *string `json:"gatewayEndpoint,omitempty" azure:"ro"` + GatewayEndpoint *string // READ-ONLY; The last time a sync occurred between the connected registry and its parent. - LastSyncTime *time.Time `json:"lastSyncTime,omitempty" azure:"ro"` + LastSyncTime *time.Time } // SyncUpdateProperties - The parameters for updating the sync properties of the connected registry with its parent. type SyncUpdateProperties struct { // The period of time for which a message is available to sync before it is expired. Specify the duration using the format // P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. - MessageTTL *string `json:"messageTtl,omitempty"` + MessageTTL *string // The cron expression indicating the schedule that the connected registry will sync with its parent. - Schedule *string `json:"schedule,omitempty"` + Schedule *string // The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S // as per ISO8601. - SyncWindow *string `json:"syncWindow,omitempty"` + SyncWindow *string } // 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 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 *LastModifiedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *LastModifiedByType } // TLSCertificateProperties - The TLS certificate properties of the connected registry login server. type TLSCertificateProperties struct { // READ-ONLY; Indicates the location of the certificates. - Location *string `json:"location,omitempty" azure:"ro"` + Location *string // READ-ONLY; The type of certificate location. - Type *CertificateType `json:"type,omitempty" azure:"ro"` + Type *CertificateType } // TLSProperties - The TLS properties of the connected registry login server. type TLSProperties struct { // READ-ONLY; The certificate used to configure HTTPS for the login server. - Certificate *TLSCertificateProperties `json:"certificate,omitempty" azure:"ro"` + Certificate *TLSCertificateProperties // READ-ONLY; Indicates whether HTTPS is enabled for the login server. - Status *TLSStatus `json:"status,omitempty" azure:"ro"` + Status *TLSStatus } // Target - The target of the event. type Target struct { // The digest of the content, as defined by the Registry V2 HTTP API Specification. - Digest *string `json:"digest,omitempty"` + Digest *string // The number of bytes of the content. Same as Size field. - Length *int64 `json:"length,omitempty"` + Length *int64 // The MIME type of the referenced object. - MediaType *string `json:"mediaType,omitempty"` + MediaType *string // The name of the artifact. - Name *string `json:"name,omitempty"` + Name *string // The repository name. - Repository *string `json:"repository,omitempty"` + Repository *string // The number of bytes of the content. Same as Length field. - Size *int64 `json:"size,omitempty"` + Size *int64 // The tag name. - Tag *string `json:"tag,omitempty"` + Tag *string // The direct URL to the content. - URL *string `json:"url,omitempty"` + URL *string // The version of the artifact. - Version *string `json:"version,omitempty"` + Version *string } // Task - The task that has the ARM resource and task properties. The task will have all information to schedule a run against // it. type Task struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // Identity for the resource. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties of a task. - Properties *TaskProperties `json:"properties,omitempty"` + Properties *TaskProperties // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // TaskListResult - The collection of tasks. type TaskListResult struct { // The URI that can be used to request the next set of paged results. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The collection value. - Value []*Task `json:"value,omitempty"` + Value []*Task } // TaskProperties - The properties of a task. type TaskProperties struct { // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the task. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The properties that describes a set of credentials that will be used when this run is invoked. - Credentials *Credentials `json:"credentials,omitempty"` + Credentials *Credentials // The value of this property indicates whether the task resource is system task or not. - IsSystemTask *bool `json:"isSystemTask,omitempty"` + IsSystemTask *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // The platform properties against which the run has to happen. - Platform *PlatformProperties `json:"platform,omitempty"` + Platform *PlatformProperties // The current status of task. - Status *TaskStatus `json:"status,omitempty"` + Status *TaskStatus // The properties of a task step. - Step TaskStepPropertiesClassification `json:"step,omitempty"` + Step TaskStepPropertiesClassification // Run timeout in seconds. - Timeout *int32 `json:"timeout,omitempty"` + Timeout *int32 // The properties that describe all triggers for the task. - Trigger *TriggerProperties `json:"trigger,omitempty"` + Trigger *TriggerProperties // READ-ONLY; The creation date of task. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; The provisioning state of the task. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // TaskPropertiesUpdateParameters - The properties for updating a task. type TaskPropertiesUpdateParameters struct { // The machine configuration of the run agent. - AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + AgentConfiguration *AgentProperties // The dedicated agent pool for the task. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The parameters that describes a set of credentials that will be used when this run is invoked. - Credentials *Credentials `json:"credentials,omitempty"` + Credentials *Credentials // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // The platform properties against which the run has to happen. - Platform *PlatformUpdateParameters `json:"platform,omitempty"` + Platform *PlatformUpdateParameters // The current status of task. - Status *TaskStatus `json:"status,omitempty"` + Status *TaskStatus // The properties for updating a task step. - Step TaskStepUpdateParametersClassification `json:"step,omitempty"` + Step TaskStepUpdateParametersClassification // Run timeout in seconds. - Timeout *int32 `json:"timeout,omitempty"` + Timeout *int32 // The properties for updating trigger properties. - Trigger *TriggerUpdateParameters `json:"trigger,omitempty"` + Trigger *TriggerUpdateParameters } // TaskRun - The task run that has the ARM resource and properties. The task run will have the information of request and // result of a run. type TaskRun struct { // Identity for the resource. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The location of the resource - Location *string `json:"location,omitempty"` + Location *string // The properties associated with the task run, i.e., request and result of the run - Properties *TaskRunProperties `json:"properties,omitempty"` + Properties *TaskRunProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // TaskRunListResult - The collection of task runs. type TaskRunListResult struct { // The URI that can be used to request the next set of paged results. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The collection value. - Value []*TaskRun `json:"value,omitempty"` + Value []*TaskRun } // TaskRunProperties - The properties of task run. type TaskRunProperties struct { // How the run should be forced to rerun even if the run request configuration has not changed - ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + ForceUpdateTag *string // The request (parameters) for the run - RunRequest RunRequestClassification `json:"runRequest,omitempty"` + RunRequest RunRequestClassification // READ-ONLY; The provisioning state of this task run - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; The result of this task run - RunResult *Run `json:"runResult,omitempty" azure:"ro"` + RunResult *Run } // TaskRunPropertiesUpdateParameters - The properties of a task run update parameters. type TaskRunPropertiesUpdateParameters struct { // How the run should be forced to rerun even if the run request configuration has not changed - ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + ForceUpdateTag *string // The request (parameters) for the new run - RunRequest RunRequestClassification `json:"runRequest,omitempty"` + RunRequest RunRequestClassification } // TaskRunRequest - The parameters for a task run request. type TaskRunRequest struct { // REQUIRED; The resource ID of task against which run has to be queued. - TaskID *string `json:"taskId,omitempty"` + TaskID *string // REQUIRED; The type of the run request. - Type *string `json:"type,omitempty"` + Type *string // The dedicated agent pool for the run. - AgentPoolName *string `json:"agentPoolName,omitempty"` + AgentPoolName *string // The value that indicates whether archiving is enabled for the run or not. - IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsArchiveEnabled *bool // The template that describes the repository and tag information for run log artifact. - LogTemplate *string `json:"logTemplate,omitempty"` + LogTemplate *string // Set of overridable parameters that can be passed when running a Task. - OverrideTaskStepProperties *OverrideTaskStepProperties `json:"overrideTaskStepProperties,omitempty"` + OverrideTaskStepProperties *OverrideTaskStepProperties } // GetRunRequest implements the RunRequestClassification interface for type TaskRunRequest. @@ -3152,16 +3151,16 @@ func (t *TaskRunRequest) GetRunRequest() *RunRequest { // TaskRunUpdateParameters - The parameters for updating a task run. type TaskRunUpdateParameters struct { // Identity for the resource. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The location of the resource - Location *string `json:"location,omitempty"` + Location *string // The properties for updating a task run. - Properties *TaskRunPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *TaskRunPropertiesUpdateParameters // The ARM resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // TaskRunsClientBeginCreateOptions contains the optional parameters for the TaskRunsClient.BeginCreate method. @@ -3209,16 +3208,16 @@ type TaskStepPropertiesClassification interface { // TaskStepProperties - Base properties for any task step. type TaskStepProperties struct { // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string // READ-ONLY; List of base image dependencies for a step. - BaseImageDependencies []*BaseImageDependency `json:"baseImageDependencies,omitempty" azure:"ro"` + BaseImageDependencies []*BaseImageDependency } // GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type TaskStepProperties. @@ -3236,13 +3235,13 @@ type TaskStepUpdateParametersClassification interface { // TaskStepUpdateParameters - Base properties for updating any task step. type TaskStepUpdateParameters struct { // REQUIRED; The type of the step. - Type *StepType `json:"type,omitempty"` + Type *StepType // The token (git PAT or SAS token of storage account blob) associated with the context for a step. - ContextAccessToken *string `json:"contextAccessToken,omitempty"` + ContextAccessToken *string // The URL(absolute or relative) of the source context for the task step. - ContextPath *string `json:"contextPath,omitempty"` + ContextPath *string } // GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type TaskStepUpdateParameters. @@ -3251,13 +3250,13 @@ func (t *TaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdate // TaskUpdateParameters - The parameters for updating a task. type TaskUpdateParameters struct { // Identity for the resource. - Identity *IdentityProperties `json:"identity,omitempty"` + Identity *IdentityProperties // The properties for updating a task. - Properties *TaskPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *TaskPropertiesUpdateParameters // The ARM resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // TasksClientBeginCreateOptions contains the optional parameters for the TasksClient.BeginCreate method. @@ -3296,130 +3295,130 @@ type TasksClientListOptions struct { // TimerTrigger - The properties of a timer trigger. type TimerTrigger struct { // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; The CRON expression for the task schedule - Schedule *string `json:"schedule,omitempty"` + Schedule *string // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus } type TimerTriggerDescriptor struct { // The occurrence that triggered the run. - ScheduleOccurrence *string `json:"scheduleOccurrence,omitempty"` + ScheduleOccurrence *string // The timer trigger name that caused the run. - TimerTriggerName *string `json:"timerTriggerName,omitempty"` + TimerTriggerName *string } // TimerTriggerUpdateParameters - The properties for updating a timer trigger. type TimerTriggerUpdateParameters struct { // REQUIRED; The name of the trigger. - Name *string `json:"name,omitempty"` + Name *string // The CRON expression for the task schedule - Schedule *string `json:"schedule,omitempty"` + Schedule *string // The current status of trigger. - Status *TriggerStatus `json:"status,omitempty"` + Status *TriggerStatus } // Token - An object that represents a token for a container registry. type Token struct { // The properties of the token. - Properties *TokenProperties `json:"properties,omitempty"` + Properties *TokenProperties // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // TokenCertificate - The properties of a certificate used for authenticating a token. type TokenCertificate struct { // Base 64 encoded string of the public certificate1 in PEM format that will be used for authenticating the token. - EncodedPemCertificate *string `json:"encodedPemCertificate,omitempty"` + EncodedPemCertificate *string // The expiry datetime of the certificate. - Expiry *time.Time `json:"expiry,omitempty"` - Name *TokenCertificateName `json:"name,omitempty"` + Expiry *time.Time + Name *TokenCertificateName // The thumbprint of the certificate. - Thumbprint *string `json:"thumbprint,omitempty"` + Thumbprint *string } // TokenCredentialsProperties - The properties of the credentials that can be used for authenticating the token. type TokenCredentialsProperties struct { - Certificates []*TokenCertificate `json:"certificates,omitempty"` - Passwords []*TokenPassword `json:"passwords,omitempty"` + Certificates []*TokenCertificate + Passwords []*TokenPassword } // TokenListResult - The result of a request to list tokens for a container registry. type TokenListResult struct { // The URI that can be used to request the next list of tokens. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. - Value []*Token `json:"value,omitempty"` + Value []*Token } // TokenPassword - The password that will be used for authenticating the token of a container registry. type TokenPassword struct { // The creation datetime of the password. - CreationTime *time.Time `json:"creationTime,omitempty"` + CreationTime *time.Time // The expiry datetime of the password. - Expiry *time.Time `json:"expiry,omitempty"` + Expiry *time.Time // The password name "password1" or "password2" - Name *TokenPasswordName `json:"name,omitempty"` + Name *TokenPasswordName // READ-ONLY; The password value. - Value *string `json:"value,omitempty" azure:"ro"` + Value *string } // TokenProperties - The properties of a token. type TokenProperties struct { // The credentials that can be used for authenticating the token. - Credentials *TokenCredentialsProperties `json:"credentials,omitempty"` + Credentials *TokenCredentialsProperties // The resource ID of the scope map to which the token will be associated with. - ScopeMapID *string `json:"scopeMapId,omitempty"` + ScopeMapID *string // The status of the token example enabled or disabled. - Status *TokenStatus `json:"status,omitempty"` + Status *TokenStatus // READ-ONLY; The creation date of scope map. - CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + CreationDate *time.Time // READ-ONLY; Provisioning state of the resource. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // TokenUpdateParameters - The parameters for updating a token. type TokenUpdateParameters struct { // The properties of the token update parameters. - Properties *TokenUpdateProperties `json:"properties,omitempty"` + Properties *TokenUpdateProperties } // TokenUpdateProperties - The parameters for updating token properties. type TokenUpdateProperties struct { // The credentials that can be used for authenticating the token. - Credentials *TokenCredentialsProperties `json:"credentials,omitempty"` + Credentials *TokenCredentialsProperties // The resource ID of the scope map to which the token will be associated with. - ScopeMapID *string `json:"scopeMapId,omitempty"` + ScopeMapID *string // The status of the token example enabled or disabled. - Status *TokenStatus `json:"status,omitempty"` + Status *TokenStatus } // TokensClientBeginCreateOptions contains the optional parameters for the TokensClient.BeginCreate method. @@ -3453,154 +3452,154 @@ type TokensClientListOptions struct { // TriggerProperties - The properties of a trigger. type TriggerProperties struct { // The trigger based on base image dependencies. - BaseImageTrigger *BaseImageTrigger `json:"baseImageTrigger,omitempty"` + BaseImageTrigger *BaseImageTrigger // The collection of triggers based on source code repository. - SourceTriggers []*SourceTrigger `json:"sourceTriggers,omitempty"` + SourceTriggers []*SourceTrigger // The collection of timer triggers. - TimerTriggers []*TimerTrigger `json:"timerTriggers,omitempty"` + TimerTriggers []*TimerTrigger } // TriggerUpdateParameters - The properties for updating triggers. type TriggerUpdateParameters struct { // The trigger based on base image dependencies. - BaseImageTrigger *BaseImageTriggerUpdateParameters `json:"baseImageTrigger,omitempty"` + BaseImageTrigger *BaseImageTriggerUpdateParameters // The collection of triggers based on source code repository. - SourceTriggers []*SourceTriggerUpdateParameters `json:"sourceTriggers,omitempty"` + SourceTriggers []*SourceTriggerUpdateParameters // The collection of timer triggers. - TimerTriggers []*TimerTriggerUpdateParameters `json:"timerTriggers,omitempty"` + TimerTriggers []*TimerTriggerUpdateParameters } // TrustPolicy - The content trust policy for a container registry. type TrustPolicy struct { // The value that indicates whether the policy is enabled or not. - Status *PolicyStatus `json:"status,omitempty"` + Status *PolicyStatus // The type of trust policy. - Type *TrustPolicyType `json:"type,omitempty"` + Type *TrustPolicyType } type UserIdentityProperties struct { // The client id of user assigned identity. - ClientID *string `json:"clientId,omitempty"` + ClientID *string // The principal id of user assigned identity. - PrincipalID *string `json:"principalId,omitempty"` + PrincipalID *string } // Webhook - An object that represents a webhook for a container registry. type Webhook struct { // REQUIRED; The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // The properties of the webhook. - Properties *WebhookProperties `json:"properties,omitempty"` + Properties *WebhookProperties // The tags of the resource. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; The resource ID. - 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; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // WebhookCreateParameters - The parameters for creating a webhook. type WebhookCreateParameters struct { // REQUIRED; The location of the webhook. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` + Location *string // The properties that the webhook will be created with. - Properties *WebhookPropertiesCreateParameters `json:"properties,omitempty"` + Properties *WebhookPropertiesCreateParameters // The tags for the webhook. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // WebhookListResult - The result of a request to list webhooks for a container registry. type WebhookListResult struct { // The URI that can be used to request the next list of webhooks. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of // webhooks. - Value []*Webhook `json:"value,omitempty"` + Value []*Webhook } // WebhookProperties - The properties of a webhook. type WebhookProperties struct { // REQUIRED; The list of actions that trigger the webhook to post notifications. - Actions []*WebhookAction `json:"actions,omitempty"` + Actions []*WebhookAction // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository // 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to // 'foo:latest'. Empty means all events. - Scope *string `json:"scope,omitempty"` + Scope *string // The status of the webhook at the time the operation was called. - Status *WebhookStatus `json:"status,omitempty"` + Status *WebhookStatus // READ-ONLY; The provisioning state of the webhook at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState } // WebhookPropertiesCreateParameters - The parameters for creating the properties of a webhook. type WebhookPropertiesCreateParameters struct { // REQUIRED; The list of actions that trigger the webhook to post notifications. - Actions []*WebhookAction `json:"actions,omitempty"` + Actions []*WebhookAction // REQUIRED; The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` + ServiceURI *string // Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders,omitempty"` + CustomHeaders map[string]*string // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository // 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to // 'foo:latest'. Empty means all events. - Scope *string `json:"scope,omitempty"` + Scope *string // The status of the webhook at the time the operation was called. - Status *WebhookStatus `json:"status,omitempty"` + Status *WebhookStatus } // WebhookPropertiesUpdateParameters - The parameters for updating the properties of a webhook. type WebhookPropertiesUpdateParameters struct { // The list of actions that trigger the webhook to post notifications. - Actions []*WebhookAction `json:"actions,omitempty"` + Actions []*WebhookAction // Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders,omitempty"` + CustomHeaders map[string]*string // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository // 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to // 'foo:latest'. Empty means all events. - Scope *string `json:"scope,omitempty"` + Scope *string // The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` + ServiceURI *string // The status of the webhook at the time the operation was called. - Status *WebhookStatus `json:"status,omitempty"` + Status *WebhookStatus } // WebhookUpdateParameters - The parameters for updating a webhook. type WebhookUpdateParameters struct { // The properties that the webhook will be updated with. - Properties *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *WebhookPropertiesUpdateParameters // The tags for the webhook. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // WebhooksClientBeginCreateOptions contains the optional parameters for the WebhooksClient.BeginCreate method. diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/models_serde.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/models_serde.go index cf7b63e37d5c..7f686e4b2b96 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/models_serde.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/operations_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/operations_client.go index 3335bdee7ae3..cfb61b3985e1 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/operations_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry @@ -48,6 +47,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -67,6 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/pipelineruns_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/pipelineruns_client.go index 5615e3ec616b..142b438a75bc 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/pipelineruns_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/pipelineruns_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *PipelineRunsClient) BeginCreate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelineRunsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelineRunsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PipelineRunsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *PipelineRunsClient) BeginCreate(ctx context.Context, resourceGroup // // Generated from API version 2023-01-01-preview func (client *PipelineRunsClient) create(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, pipelineRunCreateParameters PipelineRun, options *PipelineRunsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "PipelineRunsClient.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, registryName, pipelineRunName, pipelineRunCreateParameters, 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. @@ -111,7 +117,10 @@ func (client *PipelineRunsClient) createCreateRequest(ctx context.Context, resou reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, pipelineRunCreateParameters) + if err := runtime.MarshalAsJSON(req, pipelineRunCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a pipeline run from a container registry. @@ -129,9 +138,10 @@ func (client *PipelineRunsClient) BeginDelete(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelineRunsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelineRunsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PipelineRunsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *PipelineRunsClient) BeginDelete(ctx context.Context, resourceGroup // // Generated from API version 2023-01-01-preview func (client *PipelineRunsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "PipelineRunsClient.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, registryName, pipelineRunName, 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. @@ -192,18 +208,25 @@ func (client *PipelineRunsClient) deleteCreateRequest(ctx context.Context, resou // - pipelineRunName - The name of the pipeline run. // - options - PipelineRunsClientGetOptions contains the optional parameters for the PipelineRunsClient.Get method. func (client *PipelineRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsClientGetOptions) (PipelineRunsClientGetResponse, error) { + var err error + const operationName = "PipelineRunsClient.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, registryName, pipelineRunName, options) if err != nil { return PipelineRunsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PipelineRunsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PipelineRunsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PipelineRunsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -254,6 +277,7 @@ func (client *PipelineRunsClient) NewListPager(resourceGroupName string, registr return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PipelineRunsClientListResponse) (PipelineRunsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PipelineRunsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -273,6 +297,7 @@ func (client *PipelineRunsClient) NewListPager(resourceGroupName string, registr } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/polymorphic_helpers.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/polymorphic_helpers.go index 9b27db470ce7..bdd88e76de0f 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/polymorphic_helpers.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/polymorphic_helpers.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 armcontainerregistry @@ -32,7 +31,10 @@ func unmarshalRunRequestClassification(rawMsg json.RawMessage) (RunRequestClassi default: b = &RunRequest{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalTaskStepPropertiesClassification(rawMsg json.RawMessage) (TaskStepPropertiesClassification, error) { @@ -54,7 +56,10 @@ func unmarshalTaskStepPropertiesClassification(rawMsg json.RawMessage) (TaskStep default: b = &TaskStepProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalTaskStepUpdateParametersClassification(rawMsg json.RawMessage) (TaskStepUpdateParametersClassification, error) { @@ -76,5 +81,8 @@ func unmarshalTaskStepUpdateParametersClassification(rawMsg json.RawMessage) (Ta default: b = &TaskStepUpdateParameters{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/privateendpointconnections_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/privateendpointconnections_client.go index 17ea405e9e3f..f1cd21dc359a 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/privateendpointconnections_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/privateendpointconnections_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. // // Generated from API version 2023-01-01-preview func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, privateEndpointConnection 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, registryName, privateEndpointConnectionName, privateEndpointConnection, 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. @@ -111,7 +117,10 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, privateEndpointConnection) + if err := runtime.MarshalAsJSON(req, privateEndpointConnection); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes the specified private endpoint connection associated with the container registry. @@ -129,9 +138,10 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // // Generated from API version 2023-01-01-preview func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName 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, registryName, privateEndpointConnectionName, 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. @@ -192,18 +208,25 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, registryName 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, registryName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -255,6 +278,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListResponse) (PrivateEndpointConnectionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -274,6 +298,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/registries_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/registries_client.go index 2b2f05d21fbd..9221d6f8b7d1 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/registries_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/registries_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 armcontainerregistry @@ -53,18 +52,25 @@ func NewRegistriesClient(subscriptionID string, credential azcore.TokenCredentia // - options - RegistriesClientCheckNameAvailabilityOptions contains the optional parameters for the RegistriesClient.CheckNameAvailability // method. func (client *RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest, options *RegistriesClientCheckNameAvailabilityOptions) (RegistriesClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "RegistriesClient.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, registryNameCheckRequest, options) if err != nil { return RegistriesClientCheckNameAvailabilityResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientCheckNameAvailabilityResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientCheckNameAvailabilityResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientCheckNameAvailabilityResponse{}, err } - return client.checkNameAvailabilityHandleResponse(resp) + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. @@ -79,7 +85,10 @@ func (client *RegistriesClient) checkNameAvailabilityCreateRequest(ctx context.C reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, registryNameCheckRequest) + if err := runtime.MarshalAsJSON(req, registryNameCheckRequest); err != nil { + return nil, err + } + return req, nil } // checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. @@ -105,9 +114,10 @@ func (client *RegistriesClient) BeginCreate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -118,18 +128,24 @@ func (client *RegistriesClient) BeginCreate(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *RegistriesClient) create(ctx context.Context, resourceGroupName string, registryName string, registry Registry, options *RegistriesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.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, registryName, registry, 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. @@ -152,7 +168,10 @@ func (client *RegistriesClient) createCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, registry) + if err := runtime.MarshalAsJSON(req, registry); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a container registry. @@ -168,9 +187,10 @@ func (client *RegistriesClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -181,18 +201,24 @@ func (client *RegistriesClient) BeginDelete(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *RegistriesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.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, registryName, 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. @@ -232,9 +258,10 @@ func (client *RegistriesClient) BeginGenerateCredentials(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientGenerateCredentialsResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientGenerateCredentialsResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientGenerateCredentialsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -245,18 +272,24 @@ func (client *RegistriesClient) BeginGenerateCredentials(ctx context.Context, re // // Generated from API version 2023-01-01-preview func (client *RegistriesClient) generateCredentials(ctx context.Context, resourceGroupName string, registryName string, generateCredentialsParameters GenerateCredentialsParameters, options *RegistriesClientBeginGenerateCredentialsOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.BeginGenerateCredentials" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.generateCredentialsCreateRequest(ctx, resourceGroupName, registryName, generateCredentialsParameters, 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 } // generateCredentialsCreateRequest creates the GenerateCredentials request. @@ -279,7 +312,10 @@ func (client *RegistriesClient) generateCredentialsCreateRequest(ctx context.Con reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, generateCredentialsParameters) + if err := runtime.MarshalAsJSON(req, generateCredentialsParameters); err != nil { + return nil, err + } + return req, nil } // Get - Gets the properties of the specified container registry. @@ -290,18 +326,25 @@ func (client *RegistriesClient) generateCredentialsCreateRequest(ctx context.Con // - registryName - The name of the container registry. // - options - RegistriesClientGetOptions contains the optional parameters for the RegistriesClient.Get method. func (client *RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientGetOptions) (RegistriesClientGetResponse, error) { + var err error + const operationName = "RegistriesClient.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, registryName, options) if err != nil { return RegistriesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -345,18 +388,25 @@ func (client *RegistriesClient) getHandleResponse(resp *http.Response) (Registri // - options - RegistriesClientGetBuildSourceUploadURLOptions contains the optional parameters for the RegistriesClient.GetBuildSourceUploadURL // method. func (client *RegistriesClient) GetBuildSourceUploadURL(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientGetBuildSourceUploadURLOptions) (RegistriesClientGetBuildSourceUploadURLResponse, error) { + var err error + const operationName = "RegistriesClient.GetBuildSourceUploadURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getBuildSourceUploadURLCreateRequest(ctx, resourceGroupName, registryName, options) if err != nil { return RegistriesClientGetBuildSourceUploadURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientGetBuildSourceUploadURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientGetBuildSourceUploadURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientGetBuildSourceUploadURLResponse{}, err } - return client.getBuildSourceUploadURLHandleResponse(resp) + resp, err := client.getBuildSourceUploadURLHandleResponse(httpResp) + return resp, err } // getBuildSourceUploadURLCreateRequest creates the GetBuildSourceUploadURL request. @@ -401,18 +451,25 @@ func (client *RegistriesClient) getBuildSourceUploadURLHandleResponse(resp *http // - options - RegistriesClientGetPrivateLinkResourceOptions contains the optional parameters for the RegistriesClient.GetPrivateLinkResource // method. func (client *RegistriesClient) GetPrivateLinkResource(ctx context.Context, resourceGroupName string, registryName string, groupName string, options *RegistriesClientGetPrivateLinkResourceOptions) (RegistriesClientGetPrivateLinkResourceResponse, error) { + var err error + const operationName = "RegistriesClient.GetPrivateLinkResource" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getPrivateLinkResourceCreateRequest(ctx, resourceGroupName, registryName, groupName, options) if err != nil { return RegistriesClientGetPrivateLinkResourceResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientGetPrivateLinkResourceResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientGetPrivateLinkResourceResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientGetPrivateLinkResourceResponse{}, err } - return client.getPrivateLinkResourceHandleResponse(resp) + resp, err := client.getPrivateLinkResourceHandleResponse(httpResp) + return resp, err } // getPrivateLinkResourceCreateRequest creates the GetPrivateLinkResource request. @@ -466,9 +523,10 @@ func (client *RegistriesClient) BeginImportImage(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientImportImageResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientImportImageResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientImportImageResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -479,18 +537,24 @@ func (client *RegistriesClient) BeginImportImage(ctx context.Context, resourceGr // // Generated from API version 2023-01-01-preview func (client *RegistriesClient) importImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters, options *RegistriesClientBeginImportImageOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.BeginImportImage" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.importImageCreateRequest(ctx, resourceGroupName, registryName, parameters, 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 } // importImageCreateRequest creates the ImportImage request. @@ -512,7 +576,10 @@ func (client *RegistriesClient) importImageCreateRequest(ctx context.Context, re reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // NewListPager - Lists all the container registries under the specified subscription. @@ -525,6 +592,7 @@ func (client *RegistriesClient) NewListPager(options *RegistriesClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *RegistriesClientListResponse) (RegistriesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RegistriesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -544,6 +612,7 @@ func (client *RegistriesClient) NewListPager(options *RegistriesClientListOption } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -583,6 +652,7 @@ func (client *RegistriesClient) NewListByResourceGroupPager(resourceGroupName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *RegistriesClientListByResourceGroupResponse) (RegistriesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RegistriesClient.NewListByResourceGroupPager") var req *policy.Request var err error if page == nil { @@ -602,6 +672,7 @@ func (client *RegistriesClient) NewListByResourceGroupPager(resourceGroupName st } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -642,18 +713,25 @@ func (client *RegistriesClient) listByResourceGroupHandleResponse(resp *http.Res // - options - RegistriesClientListCredentialsOptions contains the optional parameters for the RegistriesClient.ListCredentials // method. func (client *RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientListCredentialsOptions) (RegistriesClientListCredentialsResponse, error) { + var err error + const operationName = "RegistriesClient.ListCredentials" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCredentialsCreateRequest(ctx, resourceGroupName, registryName, options) if err != nil { return RegistriesClientListCredentialsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientListCredentialsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientListCredentialsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientListCredentialsResponse{}, err } - return client.listCredentialsHandleResponse(resp) + resp, err := client.listCredentialsHandleResponse(httpResp) + return resp, err } // listCredentialsCreateRequest creates the ListCredentials request. @@ -701,6 +779,7 @@ func (client *RegistriesClient) NewListPrivateLinkResourcesPager(resourceGroupNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *RegistriesClientListPrivateLinkResourcesResponse) (RegistriesClientListPrivateLinkResourcesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RegistriesClient.NewListPrivateLinkResourcesPager") var req *policy.Request var err error if page == nil { @@ -720,6 +799,7 @@ func (client *RegistriesClient) NewListPrivateLinkResourcesPager(resourceGroupNa } return client.listPrivateLinkResourcesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -763,18 +843,25 @@ func (client *RegistriesClient) listPrivateLinkResourcesHandleResponse(resp *htt // - registryName - The name of the container registry. // - options - RegistriesClientListUsagesOptions contains the optional parameters for the RegistriesClient.ListUsages method. func (client *RegistriesClient) ListUsages(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientListUsagesOptions) (RegistriesClientListUsagesResponse, error) { + var err error + const operationName = "RegistriesClient.ListUsages" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listUsagesCreateRequest(ctx, resourceGroupName, registryName, options) if err != nil { return RegistriesClientListUsagesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientListUsagesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientListUsagesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientListUsagesResponse{}, err } - return client.listUsagesHandleResponse(resp) + resp, err := client.listUsagesHandleResponse(httpResp) + return resp, err } // listUsagesCreateRequest creates the ListUsages request. @@ -819,18 +906,25 @@ func (client *RegistriesClient) listUsagesHandleResponse(resp *http.Response) (R // - options - RegistriesClientRegenerateCredentialOptions contains the optional parameters for the RegistriesClient.RegenerateCredential // method. func (client *RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters, options *RegistriesClientRegenerateCredentialOptions) (RegistriesClientRegenerateCredentialResponse, error) { + var err error + const operationName = "RegistriesClient.RegenerateCredential" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.regenerateCredentialCreateRequest(ctx, resourceGroupName, registryName, regenerateCredentialParameters, options) if err != nil { return RegistriesClientRegenerateCredentialResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RegistriesClientRegenerateCredentialResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RegistriesClientRegenerateCredentialResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientRegenerateCredentialResponse{}, err } - return client.regenerateCredentialHandleResponse(resp) + resp, err := client.regenerateCredentialHandleResponse(httpResp) + return resp, err } // regenerateCredentialCreateRequest creates the RegenerateCredential request. @@ -853,7 +947,10 @@ func (client *RegistriesClient) regenerateCredentialCreateRequest(ctx context.Co reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, regenerateCredentialParameters) + if err := runtime.MarshalAsJSON(req, regenerateCredentialParameters); err != nil { + return nil, err + } + return req, nil } // regenerateCredentialHandleResponse handles the RegenerateCredential response. @@ -880,7 +977,8 @@ func (client *RegistriesClient) BeginScheduleRun(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[RegistriesClientScheduleRunResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[RegistriesClientScheduleRunResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientScheduleRunResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -891,18 +989,24 @@ func (client *RegistriesClient) BeginScheduleRun(ctx context.Context, resourceGr // // Generated from API version 2019-06-01-preview func (client *RegistriesClient) scheduleRun(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, options *RegistriesClientBeginScheduleRunOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.BeginScheduleRun" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.scheduleRunCreateRequest(ctx, resourceGroupName, registryName, runRequest, 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 } // scheduleRunCreateRequest creates the ScheduleRun request. @@ -925,7 +1029,10 @@ func (client *RegistriesClient) scheduleRunCreateRequest(ctx context.Context, re reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, runRequest) + if err := runtime.MarshalAsJSON(req, runRequest); err != nil { + return nil, err + } + return req, nil } // BeginUpdate - Updates a container registry with the specified parameters. @@ -942,9 +1049,10 @@ func (client *RegistriesClient) BeginUpdate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RegistriesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[RegistriesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -955,18 +1063,24 @@ func (client *RegistriesClient) BeginUpdate(ctx context.Context, resourceGroupNa // // Generated from API version 2023-01-01-preview func (client *RegistriesClient) update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters, options *RegistriesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "RegistriesClient.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, registryName, registryUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -989,5 +1103,8 @@ func (client *RegistriesClient) updateCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, registryUpdateParameters) + if err := runtime.MarshalAsJSON(req, registryUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/replications_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/replications_client.go index d1bbe0292c78..10164bc4722c 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/replications_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/replications_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 armcontainerregistry @@ -60,9 +59,10 @@ func (client *ReplicationsClient) BeginCreate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReplicationsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,18 +73,24 @@ func (client *ReplicationsClient) BeginCreate(ctx context.Context, resourceGroup // // Generated from API version 2023-01-01-preview func (client *ReplicationsClient) create(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication, options *ReplicationsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ReplicationsClient.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, registryName, replicationName, replication, 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. @@ -111,7 +117,10 @@ func (client *ReplicationsClient) createCreateRequest(ctx context.Context, resou reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, replication) + if err := runtime.MarshalAsJSON(req, replication); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a replication from a container registry. @@ -129,9 +138,10 @@ func (client *ReplicationsClient) BeginDelete(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReplicationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -142,18 +152,24 @@ func (client *ReplicationsClient) BeginDelete(ctx context.Context, resourceGroup // // Generated from API version 2023-01-01-preview func (client *ReplicationsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ReplicationsClient.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, registryName, replicationName, 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 +207,25 @@ func (client *ReplicationsClient) deleteCreateRequest(ctx context.Context, resou // - replicationName - The name of the replication. // - options - ReplicationsClientGetOptions contains the optional parameters for the ReplicationsClient.Get method. func (client *ReplicationsClient) Get(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsClientGetOptions) (ReplicationsClientGetResponse, error) { + var err error + const operationName = "ReplicationsClient.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, registryName, replicationName, options) if err != nil { return ReplicationsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReplicationsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReplicationsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReplicationsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -253,6 +276,7 @@ func (client *ReplicationsClient) NewListPager(resourceGroupName string, registr return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ReplicationsClientListResponse) (ReplicationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ReplicationsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -272,6 +296,7 @@ func (client *ReplicationsClient) NewListPager(resourceGroupName string, registr } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -323,9 +348,10 @@ func (client *ReplicationsClient) BeginUpdate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReplicationsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -336,18 +362,24 @@ func (client *ReplicationsClient) BeginUpdate(ctx context.Context, resourceGroup // // Generated from API version 2023-01-01-preview func (client *ReplicationsClient) update(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters, options *ReplicationsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ReplicationsClient.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, registryName, replicationName, replicationUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -374,5 +406,8 @@ func (client *ReplicationsClient) updateCreateRequest(ctx context.Context, resou reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, replicationUpdateParameters) + if err := runtime.MarshalAsJSON(req, replicationUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/response_types.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/response_types.go index 0fc39d96ec89..1bf3628fa197 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/response_types.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/runs_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/runs_client.go index 07ccff53724f..cd296b6de12c 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/runs_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/runs_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 armcontainerregistry @@ -59,7 +58,8 @@ func (client *RunsClient) BeginCancel(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - return runtime.NewPoller[RunsClientCancelResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[RunsClientCancelResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[RunsClientCancelResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -70,18 +70,24 @@ func (client *RunsClient) BeginCancel(ctx context.Context, resourceGroupName str // // Generated from API version 2019-06-01-preview func (client *RunsClient) cancel(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientBeginCancelOptions) (*http.Response, error) { + var err error + const operationName = "RunsClient.BeginCancel" + 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, registryName, runID, 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 } // cancelCreateRequest creates the Cancel request. @@ -120,18 +126,25 @@ func (client *RunsClient) cancelCreateRequest(ctx context.Context, resourceGroup // - runID - The run ID. // - options - RunsClientGetOptions contains the optional parameters for the RunsClient.Get method. func (client *RunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientGetOptions) (RunsClientGetResponse, error) { + var err error + const operationName = "RunsClient.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, registryName, runID, options) if err != nil { return RunsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RunsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RunsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -179,18 +192,25 @@ func (client *RunsClient) getHandleResponse(resp *http.Response) (RunsClientGetR // - runID - The run ID. // - options - RunsClientGetLogSasURLOptions contains the optional parameters for the RunsClient.GetLogSasURL method. func (client *RunsClient) GetLogSasURL(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientGetLogSasURLOptions) (RunsClientGetLogSasURLResponse, error) { + var err error + const operationName = "RunsClient.GetLogSasURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getLogSasURLCreateRequest(ctx, resourceGroupName, registryName, runID, options) if err != nil { return RunsClientGetLogSasURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RunsClientGetLogSasURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RunsClientGetLogSasURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientGetLogSasURLResponse{}, err } - return client.getLogSasURLHandleResponse(resp) + resp, err := client.getLogSasURLHandleResponse(httpResp) + return resp, err } // getLogSasURLCreateRequest creates the GetLogSasURL request. @@ -241,6 +261,7 @@ func (client *RunsClient) NewListPager(resourceGroupName string, registryName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *RunsClientListResponse) (RunsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RunsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -260,6 +281,7 @@ func (client *RunsClient) NewListPager(resourceGroupName string, registryName st } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -316,7 +338,8 @@ func (client *RunsClient) BeginUpdate(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - return runtime.NewPoller[RunsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[RunsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[RunsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -327,18 +350,24 @@ func (client *RunsClient) BeginUpdate(ctx context.Context, resourceGroupName str // // Generated from API version 2019-06-01-preview func (client *RunsClient) update(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, options *RunsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "RunsClient.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, registryName, runID, runUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -365,5 +394,8 @@ func (client *RunsClient) updateCreateRequest(ctx context.Context, resourceGroup reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, runUpdateParameters) + if err := runtime.MarshalAsJSON(req, runUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/scopemaps_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/scopemaps_client.go index 371ce21d00f7..0b9ef2bb561d 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/scopemaps_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/scopemaps_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 armcontainerregistry @@ -59,9 +58,10 @@ func (client *ScopeMapsClient) BeginCreate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ScopeMapsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -72,18 +72,24 @@ func (client *ScopeMapsClient) BeginCreate(ctx context.Context, resourceGroupNam // // Generated from API version 2023-01-01-preview func (client *ScopeMapsClient) create(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapCreateParameters ScopeMap, options *ScopeMapsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "ScopeMapsClient.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, registryName, scopeMapName, scopeMapCreateParameters, 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. @@ -110,7 +116,10 @@ func (client *ScopeMapsClient) createCreateRequest(ctx context.Context, resource reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, scopeMapCreateParameters) + if err := runtime.MarshalAsJSON(req, scopeMapCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a scope map from a container registry. @@ -127,9 +136,10 @@ func (client *ScopeMapsClient) BeginDelete(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ScopeMapsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -140,18 +150,24 @@ func (client *ScopeMapsClient) BeginDelete(ctx context.Context, resourceGroupNam // // Generated from API version 2023-01-01-preview func (client *ScopeMapsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ScopeMapsClient.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, registryName, scopeMapName, 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. @@ -190,18 +206,25 @@ func (client *ScopeMapsClient) deleteCreateRequest(ctx context.Context, resource // - scopeMapName - The name of the scope map. // - options - ScopeMapsClientGetOptions contains the optional parameters for the ScopeMapsClient.Get method. func (client *ScopeMapsClient) Get(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsClientGetOptions) (ScopeMapsClientGetResponse, error) { + var err error + const operationName = "ScopeMapsClient.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, registryName, scopeMapName, options) if err != nil { return ScopeMapsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScopeMapsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScopeMapsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScopeMapsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -252,6 +275,7 @@ func (client *ScopeMapsClient) NewListPager(resourceGroupName string, registryNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ScopeMapsClientListResponse) (ScopeMapsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScopeMapsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -271,6 +295,7 @@ func (client *ScopeMapsClient) NewListPager(resourceGroupName string, registryNa } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -321,9 +346,10 @@ func (client *ScopeMapsClient) BeginUpdate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScopeMapsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ScopeMapsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -334,18 +360,24 @@ func (client *ScopeMapsClient) BeginUpdate(ctx context.Context, resourceGroupNam // // Generated from API version 2023-01-01-preview func (client *ScopeMapsClient) update(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapUpdateParameters ScopeMapUpdateParameters, options *ScopeMapsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ScopeMapsClient.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, registryName, scopeMapName, scopeMapUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -372,5 +404,8 @@ func (client *ScopeMapsClient) updateCreateRequest(ctx context.Context, resource reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, scopeMapUpdateParameters) + if err := runtime.MarshalAsJSON(req, scopeMapUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/taskruns_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/taskruns_client.go index 66e650dfb2f1..966cff5c5ae8 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/taskruns_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/taskruns_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 armcontainerregistry @@ -59,7 +58,8 @@ func (client *TaskRunsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[TaskRunsClientCreateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TaskRunsClientCreateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TaskRunsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -70,18 +70,24 @@ func (client *TaskRunsClient) BeginCreate(ctx context.Context, resourceGroupName // // Generated from API version 2019-06-01-preview func (client *TaskRunsClient) create(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "TaskRunsClient.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, registryName, taskRunName, taskRun, 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 +114,10 @@ func (client *TaskRunsClient) createCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, taskRun) + if err := runtime.MarshalAsJSON(req, taskRun); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a specified task run resource. @@ -125,7 +134,8 @@ func (client *TaskRunsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[TaskRunsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TaskRunsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TaskRunsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -136,18 +146,24 @@ func (client *TaskRunsClient) BeginDelete(ctx context.Context, resourceGroupName // // Generated from API version 2019-06-01-preview func (client *TaskRunsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TaskRunsClient.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, registryName, taskRunName, 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 +202,25 @@ func (client *TaskRunsClient) deleteCreateRequest(ctx context.Context, resourceG // - taskRunName - The name of the task run. // - options - TaskRunsClientGetOptions contains the optional parameters for the TaskRunsClient.Get method. func (client *TaskRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientGetOptions) (TaskRunsClientGetResponse, error) { + var err error + const operationName = "TaskRunsClient.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, registryName, taskRunName, options) if err != nil { return TaskRunsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TaskRunsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TaskRunsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TaskRunsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -245,18 +268,25 @@ func (client *TaskRunsClient) getHandleResponse(resp *http.Response) (TaskRunsCl // - taskRunName - The name of the task run. // - options - TaskRunsClientGetDetailsOptions contains the optional parameters for the TaskRunsClient.GetDetails method. func (client *TaskRunsClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientGetDetailsOptions) (TaskRunsClientGetDetailsResponse, error) { + var err error + const operationName = "TaskRunsClient.GetDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) if err != nil { return TaskRunsClientGetDetailsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TaskRunsClientGetDetailsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TaskRunsClientGetDetailsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TaskRunsClientGetDetailsResponse{}, err } - return client.getDetailsHandleResponse(resp) + resp, err := client.getDetailsHandleResponse(httpResp) + return resp, err } // getDetailsCreateRequest creates the GetDetails request. @@ -307,6 +337,7 @@ func (client *TaskRunsClient) NewListPager(resourceGroupName string, registryNam return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TaskRunsClientListResponse) (TaskRunsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TaskRunsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -326,6 +357,7 @@ func (client *TaskRunsClient) NewListPager(resourceGroupName string, registryNam } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -376,7 +408,8 @@ func (client *TaskRunsClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[TaskRunsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TaskRunsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TaskRunsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -387,18 +420,24 @@ func (client *TaskRunsClient) BeginUpdate(ctx context.Context, resourceGroupName // // Generated from API version 2019-06-01-preview func (client *TaskRunsClient) update(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TaskRunsClient.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, registryName, taskRunName, updateParameters, 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 } // updateCreateRequest creates the Update request. @@ -425,5 +464,8 @@ func (client *TaskRunsClient) updateCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, updateParameters) + if err := runtime.MarshalAsJSON(req, updateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/tasks_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/tasks_client.go index 246a11cffc02..9071032e40ae 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/tasks_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/tasks_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 armcontainerregistry @@ -59,7 +58,8 @@ func (client *TasksClient) BeginCreate(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller[TasksClientCreateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TasksClientCreateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TasksClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -70,18 +70,24 @@ func (client *TasksClient) BeginCreate(ctx context.Context, resourceGroupName st // // Generated from API version 2019-06-01-preview func (client *TasksClient) create(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, options *TasksClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "TasksClient.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, registryName, taskName, taskCreateParameters, 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 +114,10 @@ func (client *TasksClient) createCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, taskCreateParameters) + if err := runtime.MarshalAsJSON(req, taskCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a specified task. @@ -125,7 +134,8 @@ func (client *TasksClient) BeginDelete(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller[TasksClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TasksClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TasksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -136,18 +146,24 @@ func (client *TasksClient) BeginDelete(ctx context.Context, resourceGroupName st // // Generated from API version 2019-06-01-preview func (client *TasksClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TasksClient.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, registryName, taskName, 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 +202,25 @@ func (client *TasksClient) deleteCreateRequest(ctx context.Context, resourceGrou // - taskName - The name of the container registry task. // - options - TasksClientGetOptions contains the optional parameters for the TasksClient.Get method. func (client *TasksClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientGetOptions) (TasksClientGetResponse, error) { + var err error + const operationName = "TasksClient.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, registryName, taskName, options) if err != nil { return TasksClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TasksClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TasksClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -245,18 +268,25 @@ func (client *TasksClient) getHandleResponse(resp *http.Response) (TasksClientGe // - taskName - The name of the container registry task. // - options - TasksClientGetDetailsOptions contains the optional parameters for the TasksClient.GetDetails method. func (client *TasksClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientGetDetailsOptions) (TasksClientGetDetailsResponse, error) { + var err error + const operationName = "TasksClient.GetDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskName, options) if err != nil { return TasksClientGetDetailsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TasksClientGetDetailsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TasksClientGetDetailsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TasksClientGetDetailsResponse{}, err } - return client.getDetailsHandleResponse(resp) + resp, err := client.getDetailsHandleResponse(httpResp) + return resp, err } // getDetailsCreateRequest creates the GetDetails request. @@ -307,6 +337,7 @@ func (client *TasksClient) NewListPager(resourceGroupName string, registryName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TasksClientListResponse) (TasksClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TasksClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -326,6 +357,7 @@ func (client *TasksClient) NewListPager(resourceGroupName string, registryName s } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -376,7 +408,8 @@ func (client *TasksClient) BeginUpdate(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller[TasksClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[TasksClientUpdateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[TasksClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -387,18 +420,24 @@ func (client *TasksClient) BeginUpdate(ctx context.Context, resourceGroupName st // // Generated from API version 2019-06-01-preview func (client *TasksClient) update(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, options *TasksClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TasksClient.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, registryName, taskName, taskUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -425,5 +464,8 @@ func (client *TasksClient) updateCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2019-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, taskUpdateParameters) + if err := runtime.MarshalAsJSON(req, taskUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/time_rfc3339.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/time_rfc3339.go index e4e6046663c0..c6e0354bd4d7 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/time_rfc3339.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/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 armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/tokens_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/tokens_client.go index 1daafe0ca0a3..3ad86fab3896 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/tokens_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/tokens_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 armcontainerregistry @@ -59,9 +58,10 @@ func (client *TokensClient) BeginCreate(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[TokensClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -72,18 +72,24 @@ func (client *TokensClient) BeginCreate(ctx context.Context, resourceGroupName s // // Generated from API version 2023-01-01-preview func (client *TokensClient) create(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenCreateParameters Token, options *TokensClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "TokensClient.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, registryName, tokenName, tokenCreateParameters, 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. @@ -110,7 +116,10 @@ func (client *TokensClient) createCreateRequest(ctx context.Context, resourceGro reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, tokenCreateParameters) + if err := runtime.MarshalAsJSON(req, tokenCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a token from a container registry. @@ -127,9 +136,10 @@ func (client *TokensClient) BeginDelete(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[TokensClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -140,18 +150,24 @@ func (client *TokensClient) BeginDelete(ctx context.Context, resourceGroupName s // // Generated from API version 2023-01-01-preview func (client *TokensClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TokensClient.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, registryName, tokenName, 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. @@ -190,18 +206,25 @@ func (client *TokensClient) deleteCreateRequest(ctx context.Context, resourceGro // - tokenName - The name of the token. // - options - TokensClientGetOptions contains the optional parameters for the TokensClient.Get method. func (client *TokensClient) Get(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensClientGetOptions) (TokensClientGetResponse, error) { + var err error + const operationName = "TokensClient.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, registryName, tokenName, options) if err != nil { return TokensClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TokensClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TokensClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TokensClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -252,6 +275,7 @@ func (client *TokensClient) NewListPager(resourceGroupName string, registryName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TokensClientListResponse) (TokensClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TokensClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -271,6 +295,7 @@ func (client *TokensClient) NewListPager(resourceGroupName string, registryName } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -321,9 +346,10 @@ func (client *TokensClient) BeginUpdate(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TokensClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[TokensClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -334,18 +360,24 @@ func (client *TokensClient) BeginUpdate(ctx context.Context, resourceGroupName s // // Generated from API version 2023-01-01-preview func (client *TokensClient) update(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenUpdateParameters TokenUpdateParameters, options *TokensClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TokensClient.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, registryName, tokenName, tokenUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -372,5 +404,8 @@ func (client *TokensClient) updateCreateRequest(ctx context.Context, resourceGro reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, tokenUpdateParameters) + if err := runtime.MarshalAsJSON(req, tokenUpdateParameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/webhooks_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/webhooks_client.go index 5feb0ce764eb..1b42729b4388 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/webhooks_client.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/webhooks_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 armcontainerregistry @@ -59,9 +58,10 @@ func (client *WebhooksClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[WebhooksClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -72,18 +72,24 @@ func (client *WebhooksClient) BeginCreate(ctx context.Context, resourceGroupName // // Generated from API version 2023-01-01-preview func (client *WebhooksClient) create(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, options *WebhooksClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "WebhooksClient.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, registryName, webhookName, webhookCreateParameters, 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. @@ -110,7 +116,10 @@ func (client *WebhooksClient) createCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, webhookCreateParameters) + if err := runtime.MarshalAsJSON(req, webhookCreateParameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a webhook from a container registry. @@ -127,9 +136,10 @@ func (client *WebhooksClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[WebhooksClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -140,18 +150,24 @@ func (client *WebhooksClient) BeginDelete(ctx context.Context, resourceGroupName // // Generated from API version 2023-01-01-preview func (client *WebhooksClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "WebhooksClient.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, registryName, webhookName, 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. @@ -189,18 +205,25 @@ func (client *WebhooksClient) deleteCreateRequest(ctx context.Context, resourceG // - webhookName - The name of the webhook. // - options - WebhooksClientGetOptions contains the optional parameters for the WebhooksClient.Get method. func (client *WebhooksClient) Get(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientGetOptions) (WebhooksClientGetResponse, error) { + var err error + const operationName = "WebhooksClient.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, registryName, webhookName, options) if err != nil { return WebhooksClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WebhooksClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WebhooksClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -249,18 +272,25 @@ func (client *WebhooksClient) getHandleResponse(resp *http.Response) (WebhooksCl // - options - WebhooksClientGetCallbackConfigOptions contains the optional parameters for the WebhooksClient.GetCallbackConfig // method. func (client *WebhooksClient) GetCallbackConfig(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientGetCallbackConfigOptions) (WebhooksClientGetCallbackConfigResponse, error) { + var err error + const operationName = "WebhooksClient.GetCallbackConfig" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCallbackConfigCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) if err != nil { return WebhooksClientGetCallbackConfigResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WebhooksClientGetCallbackConfigResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WebhooksClientGetCallbackConfigResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientGetCallbackConfigResponse{}, err } - return client.getCallbackConfigHandleResponse(resp) + resp, err := client.getCallbackConfigHandleResponse(httpResp) + return resp, err } // getCallbackConfigCreateRequest creates the GetCallbackConfig request. @@ -311,6 +341,7 @@ func (client *WebhooksClient) NewListPager(resourceGroupName string, registryNam return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WebhooksClientListResponse) (WebhooksClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WebhooksClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -330,6 +361,7 @@ func (client *WebhooksClient) NewListPager(resourceGroupName string, registryNam } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -378,6 +410,7 @@ func (client *WebhooksClient) NewListEventsPager(resourceGroupName string, regis return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WebhooksClientListEventsResponse) (WebhooksClientListEventsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WebhooksClient.NewListEventsPager") var req *policy.Request var err error if page == nil { @@ -397,6 +430,7 @@ func (client *WebhooksClient) NewListEventsPager(resourceGroupName string, regis } return client.listEventsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -445,18 +479,25 @@ func (client *WebhooksClient) listEventsHandleResponse(resp *http.Response) (Web // - webhookName - The name of the webhook. // - options - WebhooksClientPingOptions contains the optional parameters for the WebhooksClient.Ping method. func (client *WebhooksClient) Ping(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientPingOptions) (WebhooksClientPingResponse, error) { + var err error + const operationName = "WebhooksClient.Ping" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.pingCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) if err != nil { return WebhooksClientPingResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WebhooksClientPingResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WebhooksClientPingResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WebhooksClientPingResponse{}, err } - return client.pingHandleResponse(resp) + resp, err := client.pingHandleResponse(httpResp) + return resp, err } // pingCreateRequest creates the Ping request. @@ -510,9 +551,10 @@ func (client *WebhooksClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WebhooksClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[WebhooksClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -523,18 +565,24 @@ func (client *WebhooksClient) BeginUpdate(ctx context.Context, resourceGroupName // // Generated from API version 2023-01-01-preview func (client *WebhooksClient) update(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters, options *WebhooksClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WebhooksClient.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, registryName, webhookName, webhookUpdateParameters, 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 } // updateCreateRequest creates the Update request. @@ -561,5 +609,8 @@ func (client *WebhooksClient) updateCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2023-01-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, webhookUpdateParameters) + if err := runtime.MarshalAsJSON(req, webhookUpdateParameters); err != nil { + return nil, err + } + return req, nil } From cd753e6621709a2d7390feb91d0dea53b1e065e1 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Thu, 8 Jun 2023 09:49:39 -0700 Subject: [PATCH 2/3] add module setting to config file --- .../containerregistry/armcontainerregistry/autorest.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md b/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md index e96465bf3d69..0b961080068c 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/autorest.md @@ -8,6 +8,7 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/containerregistry/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/containerregistry/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION +module: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry module-version: 1.1.0-beta.2 azcore-version: 1.7.0-beta.2 generate-fakes: true From 60267c9164ac8b8c24af7952672e0a94279bae98 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Fri, 9 Jun 2023 15:25:20 -0700 Subject: [PATCH 3/3] update to latest code generator add testable fake example bump release date --- .../armcontainerregistry/CHANGELOG.md | 2 +- .../armcontainerregistry/build.go | 2 +- .../fake/agentpools_server.go | 117 +++++++-- .../fake/cacherules_server.go | 97 +++++-- .../fake/connectedregistries_server.go | 123 +++++++-- .../fake/credentialsets_server.go | 97 +++++-- .../fake/exportpipelines_server.go | 77 ++++-- .../fake/importpipelines_server.go | 77 ++++-- .../fake/operations_server.go | 2 +- .../fake/pipelineruns_server.go | 77 ++++-- .../fake/privateendpointconnections_server.go | 77 ++++-- .../fake/registries_server.go | 237 +++++++++++++----- .../fake/replications_server.go | 97 +++++-- .../armcontainerregistry/fake/runs_server.go | 109 ++++++-- .../fake/scopemaps_server.go | 97 +++++-- .../fake/taskruns_server.go | 117 +++++++-- .../armcontainerregistry/fake/tasks_server.go | 117 +++++++-- .../fake/tokens_server.go | 97 +++++-- .../fake/webhooks_server.go | 157 +++++++++--- .../armcontainerregistry/fake_example_test.go | 79 ++++++ 20 files changed, 1475 insertions(+), 380 deletions(-) create mode 100644 sdk/resourcemanager/containerregistry/armcontainerregistry/fake_example_test.go diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md b/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md index d2d1c2e14e35..d2665e67f126 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.1.0-beta.2 (2023-06-08) +## 1.1.0-beta.2 (2023-06-12) ### Features Added diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go index 9d35ebe68300..5e538cd1aab6 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/build.go @@ -2,6 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.50" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/containerregistry/armcontainerregistry +//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.51" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/containerregistry/armcontainerregistry package armcontainerregistry diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go index 3609092aeea9..b9a559e8836a 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/agentpools_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -102,12 +103,12 @@ func (a *AgentPoolsServerTransport) Do(req *http.Request) (*http.Response, error func (a *AgentPoolsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if a.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if a.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -115,7 +116,19 @@ func (a *AgentPoolsServerTransport) dispatchBeginCreate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := a.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, agentPoolNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -139,16 +152,28 @@ func (a *AgentPoolsServerTransport) dispatchBeginCreate(req *http.Request) (*htt func (a *AgentPoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if a.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if a.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, agentPoolNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -172,15 +197,27 @@ func (a *AgentPoolsServerTransport) dispatchBeginDelete(req *http.Request) (*htt func (a *AgentPoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if a.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, agentPoolNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -197,15 +234,27 @@ func (a *AgentPoolsServerTransport) dispatchGet(req *http.Request) (*http.Respon func (a *AgentPoolsServerTransport) dispatchGetQueueStatus(req *http.Request) (*http.Response, error) { if a.srv.GetQueueStatus == nil { - return nil, &nonRetriableError{errors.New("method GetQueueStatus not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetQueueStatus not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)/listQueueStatus" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listQueueStatus` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.GetQueueStatus(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.GetQueueStatus(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, agentPoolNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -222,16 +271,24 @@ func (a *AgentPoolsServerTransport) dispatchGetQueueStatus(req *http.Request) (* func (a *AgentPoolsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if a.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if a.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := a.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) a.newListPager = &resp server.PagerResponderInjectNextLinks(a.newListPager, req, func(page *armcontainerregistry.AgentPoolsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -252,12 +309,12 @@ func (a *AgentPoolsServerTransport) dispatchNewListPager(req *http.Request) (*ht func (a *AgentPoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if a.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if a.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/agentPools/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -265,7 +322,19 @@ func (a *AgentPoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := a.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("agentPoolName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, agentPoolNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go index 64b0999a5763..06df351eb968 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/cacherules_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -96,12 +97,12 @@ func (c *CacheRulesServerTransport) Do(req *http.Request) (*http.Response, error func (c *CacheRulesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if c.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if c.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cacheRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -109,7 +110,19 @@ func (c *CacheRulesServerTransport) dispatchBeginCreate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + cacheRuleNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("cacheRuleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, cacheRuleNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,16 +146,28 @@ func (c *CacheRulesServerTransport) dispatchBeginCreate(req *http.Request) (*htt func (c *CacheRulesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if c.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if c.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cacheRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + cacheRuleNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("cacheRuleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, cacheRuleNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -166,15 +191,27 @@ func (c *CacheRulesServerTransport) dispatchBeginDelete(req *http.Request) (*htt func (c *CacheRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if c.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cacheRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + cacheRuleNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("cacheRuleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, cacheRuleNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,16 +228,24 @@ func (c *CacheRulesServerTransport) dispatchGet(req *http.Request) (*http.Respon func (c *CacheRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if c.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if c.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cacheRules` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) c.newListPager = &resp server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.CacheRulesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -221,12 +266,12 @@ func (c *CacheRulesServerTransport) dispatchNewListPager(req *http.Request) (*ht func (c *CacheRulesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if c.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if c.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/cacheRules/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cacheRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -234,7 +279,19 @@ func (c *CacheRulesServerTransport) dispatchBeginUpdate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("cacheRuleName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + cacheRuleNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("cacheRuleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, cacheRuleNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go index a2db9f348cf3..bddab21fb9da 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/connectedregistries_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -103,12 +104,12 @@ func (c *ConnectedRegistriesServerTransport) Do(req *http.Request) (*http.Respon func (c *ConnectedRegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if c.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if c.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -116,7 +117,19 @@ func (c *ConnectedRegistriesServerTransport) dispatchBeginCreate(req *http.Reque if err != nil { return nil, err } - respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + connectedRegistryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("connectedRegistryName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, connectedRegistryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -140,16 +153,28 @@ func (c *ConnectedRegistriesServerTransport) dispatchBeginCreate(req *http.Reque func (c *ConnectedRegistriesServerTransport) dispatchBeginDeactivate(req *http.Request) (*http.Response, error) { if c.srv.BeginDeactivate == nil { - return nil, &nonRetriableError{errors.New("method BeginDeactivate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDeactivate not implemented")} } if c.beginDeactivate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)/deactivate" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deactivate` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.BeginDeactivate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + connectedRegistryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("connectedRegistryName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDeactivate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, connectedRegistryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -173,16 +198,28 @@ func (c *ConnectedRegistriesServerTransport) dispatchBeginDeactivate(req *http.R func (c *ConnectedRegistriesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if c.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if c.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + connectedRegistryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("connectedRegistryName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, connectedRegistryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -206,15 +243,27 @@ func (c *ConnectedRegistriesServerTransport) dispatchBeginDelete(req *http.Reque func (c *ConnectedRegistriesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if c.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + connectedRegistryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("connectedRegistryName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, connectedRegistryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -231,24 +280,36 @@ func (c *ConnectedRegistriesServerTransport) dispatchGet(req *http.Request) (*ht func (c *ConnectedRegistriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if c.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if c.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - filterParam := getOptional(qp.Get("$filter")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) var options *armcontainerregistry.ConnectedRegistriesClientListOptions if filterParam != nil { options = &armcontainerregistry.ConnectedRegistriesClientListOptions{ Filter: filterParam, } } - resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], options) + resp := c.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, options) c.newListPager = &resp server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.ConnectedRegistriesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -269,12 +330,12 @@ func (c *ConnectedRegistriesServerTransport) dispatchNewListPager(req *http.Requ func (c *ConnectedRegistriesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if c.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if c.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/connectedRegistries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/connectedRegistries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -282,7 +343,19 @@ func (c *ConnectedRegistriesServerTransport) dispatchBeginUpdate(req *http.Reque if err != nil { return nil, err } - respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("connectedRegistryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + connectedRegistryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("connectedRegistryName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, connectedRegistryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go index 2ca1797b208a..3438a4041464 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/credentialsets_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -96,12 +97,12 @@ func (c *CredentialSetsServerTransport) Do(req *http.Request) (*http.Response, e func (c *CredentialSetsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if c.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if c.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/credentialSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -109,7 +110,19 @@ func (c *CredentialSetsServerTransport) dispatchBeginCreate(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := c.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + credentialSetNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("credentialSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, credentialSetNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,16 +146,28 @@ func (c *CredentialSetsServerTransport) dispatchBeginCreate(req *http.Request) ( func (c *CredentialSetsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if c.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if c.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/credentialSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + credentialSetNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("credentialSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, credentialSetNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -166,15 +191,27 @@ func (c *CredentialSetsServerTransport) dispatchBeginDelete(req *http.Request) ( func (c *CredentialSetsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if c.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/credentialSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := c.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + credentialSetNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("credentialSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, credentialSetNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,16 +228,24 @@ func (c *CredentialSetsServerTransport) dispatchGet(req *http.Request) (*http.Re func (c *CredentialSetsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if c.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if c.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/credentialSets` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := c.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) c.newListPager = &resp server.PagerResponderInjectNextLinks(c.newListPager, req, func(page *armcontainerregistry.CredentialSetsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -221,12 +266,12 @@ func (c *CredentialSetsServerTransport) dispatchNewListPager(req *http.Request) func (c *CredentialSetsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if c.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if c.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/credentialSets/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/credentialSets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -234,7 +279,19 @@ func (c *CredentialSetsServerTransport) dispatchBeginUpdate(req *http.Request) ( if err != nil { return nil, err } - respr, errRespr := c.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("credentialSetName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + credentialSetNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("credentialSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, credentialSetNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go index 8d59f2f23578..d36b5d52d8d8 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/exportpipelines_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -89,12 +90,12 @@ func (e *ExportPipelinesServerTransport) Do(req *http.Request) (*http.Response, func (e *ExportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if e.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if e.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -102,7 +103,19 @@ func (e *ExportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) if err != nil { return nil, err } - respr, errRespr := e.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + exportPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("exportPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, exportPipelineNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -126,16 +139,28 @@ func (e *ExportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) func (e *ExportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if e.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if e.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := e.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + exportPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("exportPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, exportPipelineNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -159,15 +184,27 @@ func (e *ExportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) func (e *ExportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if e.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := e.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("exportPipelineName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + exportPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("exportPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, exportPipelineNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -184,16 +221,24 @@ func (e *ExportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.R func (e *ExportPipelinesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if e.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/exportPipelines" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportPipelines` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := e.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) e.newListPager = &resp server.PagerResponderInjectNextLinks(e.newListPager, req, func(page *armcontainerregistry.ExportPipelinesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go index 52f6784b8f4a..821f7a0183ec 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/importpipelines_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -89,12 +90,12 @@ func (i *ImportPipelinesServerTransport) Do(req *http.Request) (*http.Response, func (i *ImportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if i.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if i.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -102,7 +103,19 @@ func (i *ImportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) if err != nil { return nil, err } - respr, errRespr := i.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + importPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("importPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, importPipelineNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -126,16 +139,28 @@ func (i *ImportPipelinesServerTransport) dispatchBeginCreate(req *http.Request) func (i *ImportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if i.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if i.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := i.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + importPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("importPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, importPipelineNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -159,15 +184,27 @@ func (i *ImportPipelinesServerTransport) dispatchBeginDelete(req *http.Request) func (i *ImportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if i.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importPipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := i.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("importPipelineName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + importPipelineNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("importPipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, importPipelineNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -184,16 +221,24 @@ func (i *ImportPipelinesServerTransport) dispatchGet(req *http.Request) (*http.R func (i *ImportPipelinesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if i.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if i.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importPipelines" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importPipelines` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := i.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) i.newListPager = &resp server.PagerResponderInjectNextLinks(i.newListPager, req, func(page *armcontainerregistry.ImportPipelinesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go index 712dade6206b..8a020437c38c 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/operations_server.go @@ -67,7 +67,7 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if o.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if o.newListPager == nil { resp := o.srv.NewListPager(nil) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go index f0c03ef0720a..b05e37eca036 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/pipelineruns_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -89,12 +90,12 @@ func (p *PipelineRunsServerTransport) Do(req *http.Request) (*http.Response, err func (p *PipelineRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if p.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if p.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/pipelineRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -102,7 +103,19 @@ func (p *PipelineRunsServerTransport) dispatchBeginCreate(req *http.Request) (*h if err != nil { return nil, err } - respr, errRespr := p.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + pipelineRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, pipelineRunNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -126,16 +139,28 @@ func (p *PipelineRunsServerTransport) dispatchBeginCreate(req *http.Request) (*h func (p *PipelineRunsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if p.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if p.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/pipelineRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + pipelineRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, pipelineRunNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -159,15 +184,27 @@ func (p *PipelineRunsServerTransport) dispatchBeginDelete(req *http.Request) (*h func (p *PipelineRunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if p.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/pipelineRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("pipelineRunName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + pipelineRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, pipelineRunNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -184,16 +221,24 @@ func (p *PipelineRunsServerTransport) dispatchGet(req *http.Request) (*http.Resp func (p *PipelineRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if p.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if p.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/pipelineRuns" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/pipelineRuns` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) p.newListPager = &resp server.PagerResponderInjectNextLinks(p.newListPager, req, func(page *armcontainerregistry.PipelineRunsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go index af7dd4ed3aa2..0234cf738fc5 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/privateendpointconnections_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -89,12 +90,12 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { if p.srv.BeginCreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreateOrUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} } if p.beginCreateOrUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -102,7 +103,19 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate( if err != nil { return nil, err } - respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, privateEndpointConnectionNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -126,16 +139,28 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate( func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if p.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if p.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, privateEndpointConnectionNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -159,15 +184,27 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *htt func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if p.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, privateEndpointConnectionNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -184,16 +221,24 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if p.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if p.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) p.newListPager = &resp server.PagerResponderInjectNextLinks(p.newListPager, req, func(page *armcontainerregistry.PrivateEndpointConnectionsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go index 1e19a5f11d92..7b3459fe53ef 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/registries_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -167,11 +168,11 @@ func (r *RegistriesServerTransport) Do(req *http.Request) (*http.Response, error func (r *RegistriesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { if r.srv.CheckNameAvailability == nil { - return nil, &nonRetriableError{errors.New("method CheckNameAvailability not implemented")} + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/checkNameAvailability" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/checkNameAvailability` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -196,12 +197,12 @@ func (r *RegistriesServerTransport) dispatchCheckNameAvailability(req *http.Requ func (r *RegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if r.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if r.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -209,7 +210,15 @@ func (r *RegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := r.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -233,16 +242,24 @@ func (r *RegistriesServerTransport) dispatchBeginCreate(req *http.Request) (*htt func (r *RegistriesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if r.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if r.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -266,12 +283,12 @@ func (r *RegistriesServerTransport) dispatchBeginDelete(req *http.Request) (*htt func (r *RegistriesServerTransport) dispatchBeginGenerateCredentials(req *http.Request) (*http.Response, error) { if r.srv.BeginGenerateCredentials == nil { - return nil, &nonRetriableError{errors.New("method BeginGenerateCredentials not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateCredentials not implemented")} } if r.beginGenerateCredentials == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/generateCredentials" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generateCredentials` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -279,7 +296,15 @@ func (r *RegistriesServerTransport) dispatchBeginGenerateCredentials(req *http.R if err != nil { return nil, err } - respr, errRespr := r.srv.BeginGenerateCredentials(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginGenerateCredentials(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -303,15 +328,23 @@ func (r *RegistriesServerTransport) dispatchBeginGenerateCredentials(req *http.R func (r *RegistriesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if r.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -328,15 +361,23 @@ func (r *RegistriesServerTransport) dispatchGet(req *http.Request) (*http.Respon func (r *RegistriesServerTransport) dispatchGetBuildSourceUploadURL(req *http.Request) (*http.Response, error) { if r.srv.GetBuildSourceUploadURL == nil { - return nil, &nonRetriableError{errors.New("method GetBuildSourceUploadURL not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetBuildSourceUploadURL not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listBuildSourceUploadUrl" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listBuildSourceUploadUrl` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.GetBuildSourceUploadURL(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetBuildSourceUploadURL(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -353,15 +394,27 @@ func (r *RegistriesServerTransport) dispatchGetBuildSourceUploadURL(req *http.Re func (r *RegistriesServerTransport) dispatchGetPrivateLinkResource(req *http.Request) (*http.Response, error) { if r.srv.GetPrivateLinkResource == nil { - return nil, &nonRetriableError{errors.New("method GetPrivateLinkResource not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetPrivateLinkResource not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateLinkResources/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.GetPrivateLinkResource(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("groupName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + groupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("groupName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetPrivateLinkResource(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, groupNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -378,12 +431,12 @@ func (r *RegistriesServerTransport) dispatchGetPrivateLinkResource(req *http.Req func (r *RegistriesServerTransport) dispatchBeginImportImage(req *http.Request) (*http.Response, error) { if r.srv.BeginImportImage == nil { - return nil, &nonRetriableError{errors.New("method BeginImportImage not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginImportImage not implemented")} } if r.beginImportImage == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/importImage" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importImage` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -391,7 +444,15 @@ func (r *RegistriesServerTransport) dispatchBeginImportImage(req *http.Request) if err != nil { return nil, err } - respr, errRespr := r.srv.BeginImportImage(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginImportImage(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -415,12 +476,12 @@ func (r *RegistriesServerTransport) dispatchBeginImportImage(req *http.Request) func (r *RegistriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if r.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if r.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -445,16 +506,20 @@ func (r *RegistriesServerTransport) dispatchNewListPager(req *http.Request) (*ht func (r *RegistriesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { if r.srv.NewListByResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("method NewListByResourceGroupPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } if r.newListByResourceGroupPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := r.srv.NewListByResourceGroupPager(matches[regex.SubexpIndex("resourceGroupName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListByResourceGroupPager(resourceGroupNameUnescaped, nil) r.newListByResourceGroupPager = &resp server.PagerResponderInjectNextLinks(r.newListByResourceGroupPager, req, func(page *armcontainerregistry.RegistriesClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -475,15 +540,23 @@ func (r *RegistriesServerTransport) dispatchNewListByResourceGroupPager(req *htt func (r *RegistriesServerTransport) dispatchListCredentials(req *http.Request) (*http.Response, error) { if r.srv.ListCredentials == nil { - return nil, &nonRetriableError{errors.New("method ListCredentials not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListCredentials not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listCredentials" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCredentials` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.ListCredentials(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ListCredentials(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -500,16 +573,24 @@ func (r *RegistriesServerTransport) dispatchListCredentials(req *http.Request) ( func (r *RegistriesServerTransport) dispatchNewListPrivateLinkResourcesPager(req *http.Request) (*http.Response, error) { if r.srv.NewListPrivateLinkResourcesPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPrivateLinkResourcesPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPrivateLinkResourcesPager not implemented")} } if r.newListPrivateLinkResourcesPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/privateLinkResources" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := r.srv.NewListPrivateLinkResourcesPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPrivateLinkResourcesPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) r.newListPrivateLinkResourcesPager = &resp server.PagerResponderInjectNextLinks(r.newListPrivateLinkResourcesPager, req, func(page *armcontainerregistry.RegistriesClientListPrivateLinkResourcesResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -530,15 +611,23 @@ func (r *RegistriesServerTransport) dispatchNewListPrivateLinkResourcesPager(req func (r *RegistriesServerTransport) dispatchListUsages(req *http.Request) (*http.Response, error) { if r.srv.ListUsages == nil { - return nil, &nonRetriableError{errors.New("method ListUsages not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListUsages not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/listUsages" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listUsages` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.ListUsages(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ListUsages(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -555,11 +644,11 @@ func (r *RegistriesServerTransport) dispatchListUsages(req *http.Request) (*http func (r *RegistriesServerTransport) dispatchRegenerateCredential(req *http.Request) (*http.Response, error) { if r.srv.RegenerateCredential == nil { - return nil, &nonRetriableError{errors.New("method RegenerateCredential not implemented")} + return nil, &nonRetriableError{errors.New("fake for method RegenerateCredential not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/regenerateCredential" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateCredential` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -567,7 +656,15 @@ func (r *RegistriesServerTransport) dispatchRegenerateCredential(req *http.Reque if err != nil { return nil, err } - respr, errRespr := r.srv.RegenerateCredential(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.RegenerateCredential(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -584,12 +681,12 @@ func (r *RegistriesServerTransport) dispatchRegenerateCredential(req *http.Reque func (r *RegistriesServerTransport) dispatchBeginScheduleRun(req *http.Request) (*http.Response, error) { if r.srv.BeginScheduleRun == nil { - return nil, &nonRetriableError{errors.New("method BeginScheduleRun not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginScheduleRun not implemented")} } if r.beginScheduleRun == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scheduleRun" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scheduleRun` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -601,7 +698,15 @@ func (r *RegistriesServerTransport) dispatchBeginScheduleRun(req *http.Request) if err != nil { return nil, err } - respr, errRespr := r.srv.BeginScheduleRun(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginScheduleRun(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -625,12 +730,12 @@ func (r *RegistriesServerTransport) dispatchBeginScheduleRun(req *http.Request) func (r *RegistriesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if r.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if r.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -638,7 +743,15 @@ func (r *RegistriesServerTransport) dispatchBeginUpdate(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go index 20e99aa662d0..8ad615c43809 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/replications_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -96,12 +97,12 @@ func (r *ReplicationsServerTransport) Do(req *http.Request) (*http.Response, err func (r *ReplicationsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if r.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if r.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -109,7 +110,19 @@ func (r *ReplicationsServerTransport) dispatchBeginCreate(req *http.Request) (*h if err != nil { return nil, err } - respr, errRespr := r.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + replicationNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("replicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, replicationNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,16 +146,28 @@ func (r *ReplicationsServerTransport) dispatchBeginCreate(req *http.Request) (*h func (r *ReplicationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if r.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if r.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + replicationNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("replicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, replicationNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -166,15 +191,27 @@ func (r *ReplicationsServerTransport) dispatchBeginDelete(req *http.Request) (*h func (r *ReplicationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if r.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + replicationNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("replicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, replicationNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,16 +228,24 @@ func (r *ReplicationsServerTransport) dispatchGet(req *http.Request) (*http.Resp func (r *ReplicationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if r.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if r.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replications` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := r.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) r.newListPager = &resp server.PagerResponderInjectNextLinks(r.newListPager, req, func(page *armcontainerregistry.ReplicationsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -221,12 +266,12 @@ func (r *ReplicationsServerTransport) dispatchNewListPager(req *http.Request) (* func (r *ReplicationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if r.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if r.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/replications/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/replications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -234,7 +279,19 @@ func (r *ReplicationsServerTransport) dispatchBeginUpdate(req *http.Request) (*h if err != nil { return nil, err } - respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("replicationName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + replicationNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("replicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, replicationNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go index 87b2f546de14..4927fd699665 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/runs_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" "strconv" ) @@ -96,16 +97,28 @@ func (r *RunsServerTransport) Do(req *http.Request) (*http.Response, error) { func (r *RunsServerTransport) dispatchBeginCancel(req *http.Request) (*http.Response, error) { if r.srv.BeginCancel == nil { - return nil, &nonRetriableError{errors.New("method BeginCancel not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCancel not implemented")} } if r.beginCancel == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)/cancel" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.BeginCancel(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginCancel(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, runIDUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -129,15 +142,27 @@ func (r *RunsServerTransport) dispatchBeginCancel(req *http.Request) (*http.Resp func (r *RunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if r.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, runIDUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -154,15 +179,27 @@ func (r *RunsServerTransport) dispatchGet(req *http.Request) (*http.Response, er func (r *RunsServerTransport) dispatchGetLogSasURL(req *http.Request) (*http.Response, error) { if r.srv.GetLogSasURL == nil { - return nil, &nonRetriableError{errors.New("method GetLogSasURL not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetLogSasURL not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)/listLogSasUrl" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listLogSasUrl` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := r.srv.GetLogSasURL(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetLogSasURL(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, runIDUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -179,18 +216,34 @@ func (r *RunsServerTransport) dispatchGetLogSasURL(req *http.Request) (*http.Res func (r *RunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if r.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if r.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - filterParam := getOptional(qp.Get("$filter")) - topParam, err := parseOptional(qp.Get("$top"), func(v string) (int32, error) { + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + 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 @@ -207,7 +260,7 @@ func (r *RunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res Top: topParam, } } - resp := r.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], options) + resp := r.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, options) r.newListPager = &resp server.PagerResponderInjectNextLinks(r.newListPager, req, func(page *armcontainerregistry.RunsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -228,12 +281,12 @@ func (r *RunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res func (r *RunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if r.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if r.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/runs/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -241,7 +294,19 @@ func (r *RunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Resp if err != nil { return nil, err } - respr, errRespr := r.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("runId")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, runIDUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go index 41ca708b1fe4..943efc0a2a20 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/scopemaps_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -96,12 +97,12 @@ func (s *ScopeMapsServerTransport) Do(req *http.Request) (*http.Response, error) func (s *ScopeMapsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if s.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if s.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeMaps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -109,7 +110,19 @@ func (s *ScopeMapsServerTransport) dispatchBeginCreate(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := s.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + scopeMapNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("scopeMapName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, scopeMapNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,16 +146,28 @@ func (s *ScopeMapsServerTransport) dispatchBeginCreate(req *http.Request) (*http func (s *ScopeMapsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if s.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if s.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeMaps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := s.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + scopeMapNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("scopeMapName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, scopeMapNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -166,15 +191,27 @@ func (s *ScopeMapsServerTransport) dispatchBeginDelete(req *http.Request) (*http func (s *ScopeMapsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if s.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeMaps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := s.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + scopeMapNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("scopeMapName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, scopeMapNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,16 +228,24 @@ func (s *ScopeMapsServerTransport) dispatchGet(req *http.Request) (*http.Respons func (s *ScopeMapsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if s.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if s.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeMaps` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := s.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) s.newListPager = &resp server.PagerResponderInjectNextLinks(s.newListPager, req, func(page *armcontainerregistry.ScopeMapsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -221,12 +266,12 @@ func (s *ScopeMapsServerTransport) dispatchNewListPager(req *http.Request) (*htt func (s *ScopeMapsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if s.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if s.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/scopeMaps/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeMaps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -234,7 +279,19 @@ func (s *ScopeMapsServerTransport) dispatchBeginUpdate(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := s.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("scopeMapName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + scopeMapNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("scopeMapName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, scopeMapNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go index 80bf4519db32..4b22e71731a8 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/taskruns_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -102,12 +103,12 @@ func (t *TaskRunsServerTransport) Do(req *http.Request) (*http.Response, error) func (t *TaskRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if t.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if t.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -115,7 +116,19 @@ func (t *TaskRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskRunNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -139,16 +152,28 @@ func (t *TaskRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http. func (t *TaskRunsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if t.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if t.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskRunNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -172,15 +197,27 @@ func (t *TaskRunsServerTransport) dispatchBeginDelete(req *http.Request) (*http. func (t *TaskRunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if t.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskRunNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -197,15 +234,27 @@ func (t *TaskRunsServerTransport) dispatchGet(req *http.Request) (*http.Response func (t *TaskRunsServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { if t.srv.GetDetails == nil { - return nil, &nonRetriableError{errors.New("method GetDetails not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetDetails not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)/listDetails" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDetails` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.GetDetails(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetDetails(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskRunNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -222,16 +271,24 @@ func (t *TaskRunsServerTransport) dispatchGetDetails(req *http.Request) (*http.R func (t *TaskRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if t.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if t.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) t.newListPager = &resp server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TaskRunsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -252,12 +309,12 @@ func (t *TaskRunsServerTransport) dispatchNewListPager(req *http.Request) (*http func (t *TaskRunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if t.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if t.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/taskRuns/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -265,7 +322,19 @@ func (t *TaskRunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskRunName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskRunNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go index 2502d890dd25..6b683a6c3a15 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tasks_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -102,12 +103,12 @@ func (t *TasksServerTransport) Do(req *http.Request) (*http.Response, error) { func (t *TasksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if t.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if t.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -115,7 +116,19 @@ func (t *TasksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -139,16 +152,28 @@ func (t *TasksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Res func (t *TasksServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if t.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if t.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -172,15 +197,27 @@ func (t *TasksServerTransport) dispatchBeginDelete(req *http.Request) (*http.Res func (t *TasksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if t.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -197,15 +234,27 @@ func (t *TasksServerTransport) dispatchGet(req *http.Request) (*http.Response, e func (t *TasksServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { if t.srv.GetDetails == nil { - return nil, &nonRetriableError{errors.New("method GetDetails not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetDetails not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)/listDetails" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDetails` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.GetDetails(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetDetails(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -222,16 +271,24 @@ func (t *TasksServerTransport) dispatchGetDetails(req *http.Request) (*http.Resp func (t *TasksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if t.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if t.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) t.newListPager = &resp server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TasksClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -252,12 +309,12 @@ func (t *TasksServerTransport) dispatchNewListPager(req *http.Request) (*http.Re func (t *TasksServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if t.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if t.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tasks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -265,7 +322,19 @@ func (t *TasksServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("taskName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, taskNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go index 8518ef7175f9..317e0bf44d2c 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/tokens_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -96,12 +97,12 @@ func (t *TokensServerTransport) Do(req *http.Request) (*http.Response, error) { func (t *TokensServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if t.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if t.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tokens/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -109,7 +110,19 @@ func (t *TokensServerTransport) dispatchBeginCreate(req *http.Request) (*http.Re if err != nil { return nil, err } - respr, errRespr := t.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + tokenNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tokenName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, tokenNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,16 +146,28 @@ func (t *TokensServerTransport) dispatchBeginCreate(req *http.Request) (*http.Re func (t *TokensServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if t.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if t.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tokens/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + tokenNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tokenName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, tokenNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -166,15 +191,27 @@ func (t *TokensServerTransport) dispatchBeginDelete(req *http.Request) (*http.Re func (t *TokensServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if t.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tokens/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + tokenNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tokenName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, tokenNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -191,16 +228,24 @@ func (t *TokensServerTransport) dispatchGet(req *http.Request) (*http.Response, func (t *TokensServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if t.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if t.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tokens` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) t.newListPager = &resp server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armcontainerregistry.TokensClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -221,12 +266,12 @@ func (t *TokensServerTransport) dispatchNewListPager(req *http.Request) (*http.R func (t *TokensServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if t.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if t.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/tokens/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tokens/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -234,7 +279,19 @@ func (t *TokensServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Re if err != nil { return nil, err } - respr, errRespr := t.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("tokenName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + tokenNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tokenName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, tokenNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go index fef24f062e4c..9f50e5fc9711 100644 --- a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake/webhooks_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" "net/http" + "net/url" "regexp" ) @@ -115,12 +116,12 @@ func (w *WebhooksServerTransport) Do(req *http.Request) (*http.Response, error) func (w *WebhooksServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if w.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if w.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -128,7 +129,19 @@ func (w *WebhooksServerTransport) dispatchBeginCreate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := w.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -152,16 +165,28 @@ func (w *WebhooksServerTransport) dispatchBeginCreate(req *http.Request) (*http. func (w *WebhooksServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { if w.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("method BeginDelete not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} } if w.beginDelete == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := w.srv.BeginDelete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginDelete(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -185,15 +210,27 @@ func (w *WebhooksServerTransport) dispatchBeginDelete(req *http.Request) (*http. func (w *WebhooksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if w.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := w.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -210,15 +247,27 @@ func (w *WebhooksServerTransport) dispatchGet(req *http.Request) (*http.Response func (w *WebhooksServerTransport) dispatchGetCallbackConfig(req *http.Request) (*http.Response, error) { if w.srv.GetCallbackConfig == nil { - return nil, &nonRetriableError{errors.New("method GetCallbackConfig not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetCallbackConfig not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/getCallbackConfig" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getCallbackConfig` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := w.srv.GetCallbackConfig(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetCallbackConfig(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -235,16 +284,24 @@ func (w *WebhooksServerTransport) dispatchGetCallbackConfig(req *http.Request) ( func (w *WebhooksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if w.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if w.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := w.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameUnescaped, registryNameUnescaped, nil) w.newListPager = &resp server.PagerResponderInjectNextLinks(w.newListPager, req, func(page *armcontainerregistry.WebhooksClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -265,16 +322,28 @@ func (w *WebhooksServerTransport) dispatchNewListPager(req *http.Request) (*http func (w *WebhooksServerTransport) dispatchNewListEventsPager(req *http.Request) (*http.Response, error) { if w.srv.NewListEventsPager == nil { - return nil, &nonRetriableError{errors.New("method NewListEventsPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListEventsPager not implemented")} } if w.newListEventsPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/listEvents" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listEvents` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := w.srv.NewListEventsPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListEventsPager(resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, nil) w.newListEventsPager = &resp server.PagerResponderInjectNextLinks(w.newListEventsPager, req, func(page *armcontainerregistry.WebhooksClientListEventsResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -295,15 +364,27 @@ func (w *WebhooksServerTransport) dispatchNewListEventsPager(req *http.Request) func (w *WebhooksServerTransport) dispatchPing(req *http.Request) (*http.Response, error) { if w.srv.Ping == nil { - return nil, &nonRetriableError{errors.New("method Ping not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Ping not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)/ping" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ping` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := w.srv.Ping(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Ping(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -320,12 +401,12 @@ func (w *WebhooksServerTransport) dispatchPing(req *http.Request) (*http.Respons func (w *WebhooksServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if w.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("method BeginUpdate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } if w.beginUpdate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.ContainerRegistry/registries/(?P[a-zA-Z0-9-_]+)/webhooks/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/webhooks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -333,7 +414,19 @@ func (w *WebhooksServerTransport) dispatchBeginUpdate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := w.srv.BeginUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("registryName")], matches[regex.SubexpIndex("webhookName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + webhookNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("webhookName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginUpdate(req.Context(), resourceGroupNameUnescaped, registryNameUnescaped, webhookNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistry/fake_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake_example_test.go new file mode 100644 index 000000000000..3856ce156cbf --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistry/fake_example_test.go @@ -0,0 +1,79 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package armcontainerregistry_test + +import ( + "context" + "fmt" + "log" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry/fake" +) + +func ExampleAgentPoolsServer() { + // first, create an instance of the fake server for the client you wish to test. + // the type name of the server will be similar to the corresponding client, with + // the suffix "Server" instead of "Client". + fakeAgentPoolsServer := fake.AgentPoolsServer{ + + // next, provide implementations for the APIs you wish to fake. + // this fake corresponds to the AgentPoolsClient.Get() API. + Get: func(ctx context.Context, resourceGroupName, registryName, agentPoolName string, options *armcontainerregistry.AgentPoolsClientGetOptions) (resp azfake.Responder[armcontainerregistry.AgentPoolsClientGetResponse], errResp azfake.ErrorResponder) { + // the values of ctx, resourceGroupName, vmName, and options come from the API call. + + // the named return values resp and errResp are used to construct the response + // and are meant to be mutually exclusive. if both responses have been constructed, + // the error response is selected. + + // construct the response type, populating fields as required + agentPoolsResp := armcontainerregistry.AgentPoolsClientGetResponse{} + agentPoolsResp.ID = to.Ptr("/fake/resource/id") + + // use resp to set the desired response + resp.SetResponse(http.StatusOK, agentPoolsResp, nil) + + // to simulate the failure case, use errResp + //errResp.SetResponseError(http.StatusBadRequest, "ThisIsASimulatedError") + + return + }, + } + + // now create the corresponding client, connecting the fake server via the client options + client, err := armcontainerregistry.NewAgentPoolsClient("subscriptionID", azfake.NewTokenCredential(), &arm.ClientOptions{ + ClientOptions: azcore.ClientOptions{ + Transport: fake.NewAgentPoolsServerTransport(&fakeAgentPoolsServer), + }, + }) + if err != nil { + log.Fatal(err) + } + + // call the API. the provided values will be passed to the fake's implementation. + // the response or error values returned by the API call are from the fake. + resp, err := client.Get(context.TODO(), "fakeResourceGroup", "fakeRegistry", "fakeAgentPool", nil) + if err != nil { + log.Fatal(err) + } + + fmt.Println(*resp.ID) + + // APIs that haven't been faked will return an error + _, err = client.GetQueueStatus(context.TODO(), "fakeResourceGroup", "fakeRegistry", "fakeAgentPool", nil) + + fmt.Println(err.Error()) + + // Output: + // /fake/resource/id + // fake for method GetQueueStatus not implemented +}