sdk/resourcemanager/apimanagement/armapimanagement/fake/workspacenamedvalue_server.go (515 lines of code) (raw):

// Copyright (c) Microsoft Corporation. All rights 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/apimanagement/armapimanagement/v3" "net/http" "net/url" "regexp" "strconv" ) // WorkspaceNamedValueServer is a fake server for instances of the armapimanagement.WorkspaceNamedValueClient type. type WorkspaceNamedValueServer struct { // BeginCreateOrUpdate is the fake for method WorkspaceNamedValueClient.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, parameters armapimanagement.NamedValueCreateContract, options *armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method WorkspaceNamedValueClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent Delete func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, options *armapimanagement.WorkspaceNamedValueClientDeleteOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method WorkspaceNamedValueClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientGetOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientGetResponse], errResp azfake.ErrorResponder) // GetEntityTag is the fake for method WorkspaceNamedValueClient.GetEntityTag // HTTP status codes to indicate success: http.StatusOK GetEntityTag func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientGetEntityTagOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientGetEntityTagResponse], errResp azfake.ErrorResponder) // NewListByServicePager is the fake for method WorkspaceNamedValueClient.NewListByServicePager // HTTP status codes to indicate success: http.StatusOK NewListByServicePager func(resourceGroupName string, serviceName string, workspaceID string, options *armapimanagement.WorkspaceNamedValueClientListByServiceOptions) (resp azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]) // ListValue is the fake for method WorkspaceNamedValueClient.ListValue // HTTP status codes to indicate success: http.StatusOK ListValue func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientListValueOptions) (resp azfake.Responder[armapimanagement.WorkspaceNamedValueClientListValueResponse], errResp azfake.ErrorResponder) // BeginRefreshSecret is the fake for method WorkspaceNamedValueClient.BeginRefreshSecret // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted BeginRefreshSecret func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, options *armapimanagement.WorkspaceNamedValueClientBeginRefreshSecretOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse], errResp azfake.ErrorResponder) // BeginUpdate is the fake for method WorkspaceNamedValueClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted BeginUpdate func(ctx context.Context, resourceGroupName string, serviceName string, workspaceID string, namedValueID string, ifMatch string, parameters armapimanagement.NamedValueUpdateParameters, options *armapimanagement.WorkspaceNamedValueClientBeginUpdateOptions) (resp azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse], errResp azfake.ErrorResponder) } // NewWorkspaceNamedValueServerTransport creates a new instance of WorkspaceNamedValueServerTransport with the provided implementation. // The returned WorkspaceNamedValueServerTransport instance is connected to an instance of armapimanagement.WorkspaceNamedValueClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewWorkspaceNamedValueServerTransport(srv *WorkspaceNamedValueServer) *WorkspaceNamedValueServerTransport { return &WorkspaceNamedValueServerTransport{ srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse]](), newListByServicePager: newTracker[azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]](), beginRefreshSecret: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse]](), } } // WorkspaceNamedValueServerTransport connects instances of armapimanagement.WorkspaceNamedValueClient to instances of WorkspaceNamedValueServer. // Don't use this type directly, use NewWorkspaceNamedValueServerTransport instead. type WorkspaceNamedValueServerTransport struct { srv *WorkspaceNamedValueServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientCreateOrUpdateResponse]] newListByServicePager *tracker[azfake.PagerResponder[armapimanagement.WorkspaceNamedValueClientListByServiceResponse]] beginRefreshSecret *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientRefreshSecretResponse]] beginUpdate *tracker[azfake.PollerResponder[armapimanagement.WorkspaceNamedValueClientUpdateResponse]] } // Do implements the policy.Transporter interface for WorkspaceNamedValueServerTransport. func (w *WorkspaceNamedValueServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } return w.dispatchToMethodFake(req, method) } func (w *WorkspaceNamedValueServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { resultChan := make(chan result) defer close(resultChan) go func() { var intercepted bool var res result if workspaceNamedValueServerTransportInterceptor != nil { res.resp, res.err, intercepted = workspaceNamedValueServerTransportInterceptor.Do(req) } if !intercepted { switch method { case "WorkspaceNamedValueClient.BeginCreateOrUpdate": res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) case "WorkspaceNamedValueClient.Delete": res.resp, res.err = w.dispatchDelete(req) case "WorkspaceNamedValueClient.Get": res.resp, res.err = w.dispatchGet(req) case "WorkspaceNamedValueClient.GetEntityTag": res.resp, res.err = w.dispatchGetEntityTag(req) case "WorkspaceNamedValueClient.NewListByServicePager": res.resp, res.err = w.dispatchNewListByServicePager(req) case "WorkspaceNamedValueClient.ListValue": res.resp, res.err = w.dispatchListValue(req) case "WorkspaceNamedValueClient.BeginRefreshSecret": res.resp, res.err = w.dispatchBeginRefreshSecret(req) case "WorkspaceNamedValueClient.BeginUpdate": res.resp, res.err = w.dispatchBeginUpdate(req) default: res.err = fmt.Errorf("unhandled API %s", method) } } select { case resultChan <- res: case <-req.Context().Done(): } }() select { case <-req.Context().Done(): return nil, req.Context().Err() case res := <-resultChan: return res.resp, res.err } } func (w *WorkspaceNamedValueServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { if w.srv.BeginCreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} } beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) if beginCreateOrUpdate == nil { const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapimanagement.NamedValueCreateContract](req) if err != nil { return nil, err } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) var options *armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions if ifMatchParam != nil { options = &armapimanagement.WorkspaceNamedValueClientBeginCreateOrUpdateOptions{ IfMatch: ifMatchParam, } } respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, body, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginCreateOrUpdate = &respr w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) } resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { w.beginCreateOrUpdate.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} } if !server.PollerResponderMore(beginCreateOrUpdate) { w.beginCreateOrUpdate.remove(req) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if w.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, getHeaderValue(req.Header, "If-Match"), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if w.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, 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).NamedValueContract, req) if err != nil { return nil, err } if val := server.GetResponse(respr).ETag; val != nil { resp.Header.Set("ETag", *val) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchGetEntityTag(req *http.Request) (*http.Response, error) { if w.srv.GetEntityTag == nil { return nil, &nonRetriableError{errors.New("fake for method GetEntityTag not implemented")} } const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.GetEntityTag(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } respContent := server.GetResponseContent(respr) if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } resp, err := server.NewResponse(respContent, req, nil) if err != nil { return nil, err } if val := server.GetResponse(respr).ETag; val != nil { resp.Header.Set("ETag", *val) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchNewListByServicePager(req *http.Request) (*http.Response, error) { if w.srv.NewListByServicePager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByServicePager not implemented")} } newListByServicePager := w.newListByServicePager.get(req) if newListByServicePager == nil { const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) 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 } return int32(p), nil }) if err != nil { return nil, err } skipUnescaped, err := url.QueryUnescape(qp.Get("$skip")) if err != nil { return nil, err } skipParam, err := parseOptional(skipUnescaped, 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 } isKeyVaultRefreshFailedUnescaped, err := url.QueryUnescape(qp.Get("isKeyVaultRefreshFailed")) if err != nil { return nil, err } isKeyVaultRefreshFailedParam := getOptional(armapimanagement.KeyVaultRefreshState(isKeyVaultRefreshFailedUnescaped)) var options *armapimanagement.WorkspaceNamedValueClientListByServiceOptions if filterParam != nil || topParam != nil || skipParam != nil || isKeyVaultRefreshFailedParam != nil { options = &armapimanagement.WorkspaceNamedValueClientListByServiceOptions{ Filter: filterParam, Top: topParam, Skip: skipParam, IsKeyVaultRefreshFailed: isKeyVaultRefreshFailedParam, } } resp := w.srv.NewListByServicePager(resourceGroupNameParam, serviceNameParam, workspaceIDParam, options) newListByServicePager = &resp w.newListByServicePager.add(req, newListByServicePager) server.PagerResponderInjectNextLinks(newListByServicePager, req, func(page *armapimanagement.WorkspaceNamedValueClientListByServiceResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } resp, err := server.PagerResponderNext(newListByServicePager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { w.newListByServicePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListByServicePager) { w.newListByServicePager.remove(req) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchListValue(req *http.Request) (*http.Response, error) { if w.srv.ListValue == nil { return nil, &nonRetriableError{errors.New("fake for method ListValue not implemented")} } const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listValue` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.ListValue(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, 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).NamedValueSecretContract, req) if err != nil { return nil, err } if val := server.GetResponse(respr).ETag; val != nil { resp.Header.Set("ETag", *val) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchBeginRefreshSecret(req *http.Request) (*http.Response, error) { if w.srv.BeginRefreshSecret == nil { return nil, &nonRetriableError{errors.New("fake for method BeginRefreshSecret not implemented")} } beginRefreshSecret := w.beginRefreshSecret.get(req) if beginRefreshSecret == nil { const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/refreshSecret` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.BeginRefreshSecret(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginRefreshSecret = &respr w.beginRefreshSecret.add(req, beginRefreshSecret) } resp, err := server.PollerResponderNext(beginRefreshSecret, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { w.beginRefreshSecret.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginRefreshSecret) { w.beginRefreshSecret.remove(req) } return resp, nil } func (w *WorkspaceNamedValueServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { if w.srv.BeginUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } beginUpdate := w.beginUpdate.get(req) if beginUpdate == nil { const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ApiManagement/service/(?P<serviceName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workspaces/(?P<workspaceId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/namedValues/(?P<namedValueId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armapimanagement.NamedValueUpdateParameters](req) if err != nil { return nil, err } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } serviceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("serviceName")]) if err != nil { return nil, err } workspaceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("workspaceId")]) if err != nil { return nil, err } namedValueIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("namedValueId")]) if err != nil { return nil, err } respr, errRespr := w.srv.BeginUpdate(req.Context(), resourceGroupNameParam, serviceNameParam, workspaceIDParam, namedValueIDParam, getHeaderValue(req.Header, "If-Match"), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginUpdate = &respr w.beginUpdate.add(req, beginUpdate) } resp, err := server.PollerResponderNext(beginUpdate, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { w.beginUpdate.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { w.beginUpdate.remove(req) } return resp, nil } // set this to conditionally intercept incoming requests to WorkspaceNamedValueServerTransport var workspaceNamedValueServerTransportInterceptor interface { // Do returns true if the server transport should use the returned response/error Do(*http.Request) (*http.Response, error, bool) }