github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/fake/virtualhubs_server.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // Licensed under the MIT License. See License.txt in the project root for license information. 6 // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. 7 // Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9 package fake 10 11 import ( 12 "context" 13 "errors" 14 "fmt" 15 azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" 16 "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" 17 "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" 18 "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" 19 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6" 20 "net/http" 21 "net/url" 22 "reflect" 23 "regexp" 24 ) 25 26 // VirtualHubsServer is a fake server for instances of the armnetwork.VirtualHubsClient type. 27 type VirtualHubsServer struct { 28 // BeginCreateOrUpdate is the fake for method VirtualHubsClient.BeginCreateOrUpdate 29 // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated 30 BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualHubName string, virtualHubParameters armnetwork.VirtualHub, options *armnetwork.VirtualHubsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnetwork.VirtualHubsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) 31 32 // BeginDelete is the fake for method VirtualHubsClient.BeginDelete 33 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent 34 BeginDelete func(ctx context.Context, resourceGroupName string, virtualHubName string, options *armnetwork.VirtualHubsClientBeginDeleteOptions) (resp azfake.PollerResponder[armnetwork.VirtualHubsClientDeleteResponse], errResp azfake.ErrorResponder) 35 36 // Get is the fake for method VirtualHubsClient.Get 37 // HTTP status codes to indicate success: http.StatusOK 38 Get func(ctx context.Context, resourceGroupName string, virtualHubName string, options *armnetwork.VirtualHubsClientGetOptions) (resp azfake.Responder[armnetwork.VirtualHubsClientGetResponse], errResp azfake.ErrorResponder) 39 40 // BeginGetEffectiveVirtualHubRoutes is the fake for method VirtualHubsClient.BeginGetEffectiveVirtualHubRoutes 41 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 42 BeginGetEffectiveVirtualHubRoutes func(ctx context.Context, resourceGroupName string, virtualHubName string, options *armnetwork.VirtualHubsClientBeginGetEffectiveVirtualHubRoutesOptions) (resp azfake.PollerResponder[armnetwork.VirtualHubsClientGetEffectiveVirtualHubRoutesResponse], errResp azfake.ErrorResponder) 43 44 // BeginGetInboundRoutes is the fake for method VirtualHubsClient.BeginGetInboundRoutes 45 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 46 BeginGetInboundRoutes func(ctx context.Context, resourceGroupName string, virtualHubName string, getInboundRoutesParameters armnetwork.GetInboundRoutesParameters, options *armnetwork.VirtualHubsClientBeginGetInboundRoutesOptions) (resp azfake.PollerResponder[armnetwork.VirtualHubsClientGetInboundRoutesResponse], errResp azfake.ErrorResponder) 47 48 // BeginGetOutboundRoutes is the fake for method VirtualHubsClient.BeginGetOutboundRoutes 49 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 50 BeginGetOutboundRoutes func(ctx context.Context, resourceGroupName string, virtualHubName string, getOutboundRoutesParameters armnetwork.GetOutboundRoutesParameters, options *armnetwork.VirtualHubsClientBeginGetOutboundRoutesOptions) (resp azfake.PollerResponder[armnetwork.VirtualHubsClientGetOutboundRoutesResponse], errResp azfake.ErrorResponder) 51 52 // NewListPager is the fake for method VirtualHubsClient.NewListPager 53 // HTTP status codes to indicate success: http.StatusOK 54 NewListPager func(options *armnetwork.VirtualHubsClientListOptions) (resp azfake.PagerResponder[armnetwork.VirtualHubsClientListResponse]) 55 56 // NewListByResourceGroupPager is the fake for method VirtualHubsClient.NewListByResourceGroupPager 57 // HTTP status codes to indicate success: http.StatusOK 58 NewListByResourceGroupPager func(resourceGroupName string, options *armnetwork.VirtualHubsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armnetwork.VirtualHubsClientListByResourceGroupResponse]) 59 60 // UpdateTags is the fake for method VirtualHubsClient.UpdateTags 61 // HTTP status codes to indicate success: http.StatusOK 62 UpdateTags func(ctx context.Context, resourceGroupName string, virtualHubName string, virtualHubParameters armnetwork.TagsObject, options *armnetwork.VirtualHubsClientUpdateTagsOptions) (resp azfake.Responder[armnetwork.VirtualHubsClientUpdateTagsResponse], errResp azfake.ErrorResponder) 63 } 64 65 // NewVirtualHubsServerTransport creates a new instance of VirtualHubsServerTransport with the provided implementation. 66 // The returned VirtualHubsServerTransport instance is connected to an instance of armnetwork.VirtualHubsClient via the 67 // azcore.ClientOptions.Transporter field in the client's constructor parameters. 68 func NewVirtualHubsServerTransport(srv *VirtualHubsServer) *VirtualHubsServerTransport { 69 return &VirtualHubsServerTransport{ 70 srv: srv, 71 beginCreateOrUpdate: newTracker[azfake.PollerResponder[armnetwork.VirtualHubsClientCreateOrUpdateResponse]](), 72 beginDelete: newTracker[azfake.PollerResponder[armnetwork.VirtualHubsClientDeleteResponse]](), 73 beginGetEffectiveVirtualHubRoutes: newTracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetEffectiveVirtualHubRoutesResponse]](), 74 beginGetInboundRoutes: newTracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetInboundRoutesResponse]](), 75 beginGetOutboundRoutes: newTracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetOutboundRoutesResponse]](), 76 newListPager: newTracker[azfake.PagerResponder[armnetwork.VirtualHubsClientListResponse]](), 77 newListByResourceGroupPager: newTracker[azfake.PagerResponder[armnetwork.VirtualHubsClientListByResourceGroupResponse]](), 78 } 79 } 80 81 // VirtualHubsServerTransport connects instances of armnetwork.VirtualHubsClient to instances of VirtualHubsServer. 82 // Don't use this type directly, use NewVirtualHubsServerTransport instead. 83 type VirtualHubsServerTransport struct { 84 srv *VirtualHubsServer 85 beginCreateOrUpdate *tracker[azfake.PollerResponder[armnetwork.VirtualHubsClientCreateOrUpdateResponse]] 86 beginDelete *tracker[azfake.PollerResponder[armnetwork.VirtualHubsClientDeleteResponse]] 87 beginGetEffectiveVirtualHubRoutes *tracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetEffectiveVirtualHubRoutesResponse]] 88 beginGetInboundRoutes *tracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetInboundRoutesResponse]] 89 beginGetOutboundRoutes *tracker[azfake.PollerResponder[armnetwork.VirtualHubsClientGetOutboundRoutesResponse]] 90 newListPager *tracker[azfake.PagerResponder[armnetwork.VirtualHubsClientListResponse]] 91 newListByResourceGroupPager *tracker[azfake.PagerResponder[armnetwork.VirtualHubsClientListByResourceGroupResponse]] 92 } 93 94 // Do implements the policy.Transporter interface for VirtualHubsServerTransport. 95 func (v *VirtualHubsServerTransport) Do(req *http.Request) (*http.Response, error) { 96 rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) 97 method, ok := rawMethod.(string) 98 if !ok { 99 return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} 100 } 101 102 var resp *http.Response 103 var err error 104 105 switch method { 106 case "VirtualHubsClient.BeginCreateOrUpdate": 107 resp, err = v.dispatchBeginCreateOrUpdate(req) 108 case "VirtualHubsClient.BeginDelete": 109 resp, err = v.dispatchBeginDelete(req) 110 case "VirtualHubsClient.Get": 111 resp, err = v.dispatchGet(req) 112 case "VirtualHubsClient.BeginGetEffectiveVirtualHubRoutes": 113 resp, err = v.dispatchBeginGetEffectiveVirtualHubRoutes(req) 114 case "VirtualHubsClient.BeginGetInboundRoutes": 115 resp, err = v.dispatchBeginGetInboundRoutes(req) 116 case "VirtualHubsClient.BeginGetOutboundRoutes": 117 resp, err = v.dispatchBeginGetOutboundRoutes(req) 118 case "VirtualHubsClient.NewListPager": 119 resp, err = v.dispatchNewListPager(req) 120 case "VirtualHubsClient.NewListByResourceGroupPager": 121 resp, err = v.dispatchNewListByResourceGroupPager(req) 122 case "VirtualHubsClient.UpdateTags": 123 resp, err = v.dispatchUpdateTags(req) 124 default: 125 err = fmt.Errorf("unhandled API %s", method) 126 } 127 128 if err != nil { 129 return nil, err 130 } 131 132 return resp, nil 133 } 134 135 func (v *VirtualHubsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { 136 if v.srv.BeginCreateOrUpdate == nil { 137 return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} 138 } 139 beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) 140 if beginCreateOrUpdate == nil { 141 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 142 regex := regexp.MustCompile(regexStr) 143 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 144 if matches == nil || len(matches) < 3 { 145 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 146 } 147 body, err := server.UnmarshalRequestAsJSON[armnetwork.VirtualHub](req) 148 if err != nil { 149 return nil, err 150 } 151 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 152 if err != nil { 153 return nil, err 154 } 155 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 156 if err != nil { 157 return nil, err 158 } 159 respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, virtualHubNameParam, body, nil) 160 if respErr := server.GetError(errRespr, req); respErr != nil { 161 return nil, respErr 162 } 163 beginCreateOrUpdate = &respr 164 v.beginCreateOrUpdate.add(req, beginCreateOrUpdate) 165 } 166 167 resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) 168 if err != nil { 169 return nil, err 170 } 171 172 if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { 173 v.beginCreateOrUpdate.remove(req) 174 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} 175 } 176 if !server.PollerResponderMore(beginCreateOrUpdate) { 177 v.beginCreateOrUpdate.remove(req) 178 } 179 180 return resp, nil 181 } 182 183 func (v *VirtualHubsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { 184 if v.srv.BeginDelete == nil { 185 return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} 186 } 187 beginDelete := v.beginDelete.get(req) 188 if beginDelete == nil { 189 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 190 regex := regexp.MustCompile(regexStr) 191 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 192 if matches == nil || len(matches) < 3 { 193 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 194 } 195 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 196 if err != nil { 197 return nil, err 198 } 199 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 200 if err != nil { 201 return nil, err 202 } 203 respr, errRespr := v.srv.BeginDelete(req.Context(), resourceGroupNameParam, virtualHubNameParam, nil) 204 if respErr := server.GetError(errRespr, req); respErr != nil { 205 return nil, respErr 206 } 207 beginDelete = &respr 208 v.beginDelete.add(req, beginDelete) 209 } 210 211 resp, err := server.PollerResponderNext(beginDelete, req) 212 if err != nil { 213 return nil, err 214 } 215 216 if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { 217 v.beginDelete.remove(req) 218 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} 219 } 220 if !server.PollerResponderMore(beginDelete) { 221 v.beginDelete.remove(req) 222 } 223 224 return resp, nil 225 } 226 227 func (v *VirtualHubsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { 228 if v.srv.Get == nil { 229 return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} 230 } 231 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 232 regex := regexp.MustCompile(regexStr) 233 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 234 if matches == nil || len(matches) < 3 { 235 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 236 } 237 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 238 if err != nil { 239 return nil, err 240 } 241 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 242 if err != nil { 243 return nil, err 244 } 245 respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, virtualHubNameParam, nil) 246 if respErr := server.GetError(errRespr, req); respErr != nil { 247 return nil, respErr 248 } 249 respContent := server.GetResponseContent(respr) 250 if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { 251 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} 252 } 253 resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VirtualHub, req) 254 if err != nil { 255 return nil, err 256 } 257 return resp, nil 258 } 259 260 func (v *VirtualHubsServerTransport) dispatchBeginGetEffectiveVirtualHubRoutes(req *http.Request) (*http.Response, error) { 261 if v.srv.BeginGetEffectiveVirtualHubRoutes == nil { 262 return nil, &nonRetriableError{errors.New("fake for method BeginGetEffectiveVirtualHubRoutes not implemented")} 263 } 264 beginGetEffectiveVirtualHubRoutes := v.beginGetEffectiveVirtualHubRoutes.get(req) 265 if beginGetEffectiveVirtualHubRoutes == nil { 266 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/effectiveRoutes` 267 regex := regexp.MustCompile(regexStr) 268 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 269 if matches == nil || len(matches) < 3 { 270 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 271 } 272 body, err := server.UnmarshalRequestAsJSON[armnetwork.EffectiveRoutesParameters](req) 273 if err != nil { 274 return nil, err 275 } 276 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 277 if err != nil { 278 return nil, err 279 } 280 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 281 if err != nil { 282 return nil, err 283 } 284 var options *armnetwork.VirtualHubsClientBeginGetEffectiveVirtualHubRoutesOptions 285 if !reflect.ValueOf(body).IsZero() { 286 options = &armnetwork.VirtualHubsClientBeginGetEffectiveVirtualHubRoutesOptions{ 287 EffectiveRoutesParameters: &body, 288 } 289 } 290 respr, errRespr := v.srv.BeginGetEffectiveVirtualHubRoutes(req.Context(), resourceGroupNameParam, virtualHubNameParam, options) 291 if respErr := server.GetError(errRespr, req); respErr != nil { 292 return nil, respErr 293 } 294 beginGetEffectiveVirtualHubRoutes = &respr 295 v.beginGetEffectiveVirtualHubRoutes.add(req, beginGetEffectiveVirtualHubRoutes) 296 } 297 298 resp, err := server.PollerResponderNext(beginGetEffectiveVirtualHubRoutes, req) 299 if err != nil { 300 return nil, err 301 } 302 303 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 304 v.beginGetEffectiveVirtualHubRoutes.remove(req) 305 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 306 } 307 if !server.PollerResponderMore(beginGetEffectiveVirtualHubRoutes) { 308 v.beginGetEffectiveVirtualHubRoutes.remove(req) 309 } 310 311 return resp, nil 312 } 313 314 func (v *VirtualHubsServerTransport) dispatchBeginGetInboundRoutes(req *http.Request) (*http.Response, error) { 315 if v.srv.BeginGetInboundRoutes == nil { 316 return nil, &nonRetriableError{errors.New("fake for method BeginGetInboundRoutes not implemented")} 317 } 318 beginGetInboundRoutes := v.beginGetInboundRoutes.get(req) 319 if beginGetInboundRoutes == nil { 320 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inboundRoutes` 321 regex := regexp.MustCompile(regexStr) 322 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 323 if matches == nil || len(matches) < 3 { 324 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 325 } 326 body, err := server.UnmarshalRequestAsJSON[armnetwork.GetInboundRoutesParameters](req) 327 if err != nil { 328 return nil, err 329 } 330 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 331 if err != nil { 332 return nil, err 333 } 334 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 335 if err != nil { 336 return nil, err 337 } 338 respr, errRespr := v.srv.BeginGetInboundRoutes(req.Context(), resourceGroupNameParam, virtualHubNameParam, body, nil) 339 if respErr := server.GetError(errRespr, req); respErr != nil { 340 return nil, respErr 341 } 342 beginGetInboundRoutes = &respr 343 v.beginGetInboundRoutes.add(req, beginGetInboundRoutes) 344 } 345 346 resp, err := server.PollerResponderNext(beginGetInboundRoutes, req) 347 if err != nil { 348 return nil, err 349 } 350 351 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 352 v.beginGetInboundRoutes.remove(req) 353 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 354 } 355 if !server.PollerResponderMore(beginGetInboundRoutes) { 356 v.beginGetInboundRoutes.remove(req) 357 } 358 359 return resp, nil 360 } 361 362 func (v *VirtualHubsServerTransport) dispatchBeginGetOutboundRoutes(req *http.Request) (*http.Response, error) { 363 if v.srv.BeginGetOutboundRoutes == nil { 364 return nil, &nonRetriableError{errors.New("fake for method BeginGetOutboundRoutes not implemented")} 365 } 366 beginGetOutboundRoutes := v.beginGetOutboundRoutes.get(req) 367 if beginGetOutboundRoutes == nil { 368 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/outboundRoutes` 369 regex := regexp.MustCompile(regexStr) 370 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 371 if matches == nil || len(matches) < 3 { 372 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 373 } 374 body, err := server.UnmarshalRequestAsJSON[armnetwork.GetOutboundRoutesParameters](req) 375 if err != nil { 376 return nil, err 377 } 378 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 379 if err != nil { 380 return nil, err 381 } 382 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 383 if err != nil { 384 return nil, err 385 } 386 respr, errRespr := v.srv.BeginGetOutboundRoutes(req.Context(), resourceGroupNameParam, virtualHubNameParam, body, nil) 387 if respErr := server.GetError(errRespr, req); respErr != nil { 388 return nil, respErr 389 } 390 beginGetOutboundRoutes = &respr 391 v.beginGetOutboundRoutes.add(req, beginGetOutboundRoutes) 392 } 393 394 resp, err := server.PollerResponderNext(beginGetOutboundRoutes, req) 395 if err != nil { 396 return nil, err 397 } 398 399 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 400 v.beginGetOutboundRoutes.remove(req) 401 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 402 } 403 if !server.PollerResponderMore(beginGetOutboundRoutes) { 404 v.beginGetOutboundRoutes.remove(req) 405 } 406 407 return resp, nil 408 } 409 410 func (v *VirtualHubsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { 411 if v.srv.NewListPager == nil { 412 return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} 413 } 414 newListPager := v.newListPager.get(req) 415 if newListPager == nil { 416 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs` 417 regex := regexp.MustCompile(regexStr) 418 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 419 if matches == nil || len(matches) < 1 { 420 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 421 } 422 resp := v.srv.NewListPager(nil) 423 newListPager = &resp 424 v.newListPager.add(req, newListPager) 425 server.PagerResponderInjectNextLinks(newListPager, req, func(page *armnetwork.VirtualHubsClientListResponse, createLink func() string) { 426 page.NextLink = to.Ptr(createLink()) 427 }) 428 } 429 resp, err := server.PagerResponderNext(newListPager, req) 430 if err != nil { 431 return nil, err 432 } 433 if !contains([]int{http.StatusOK}, resp.StatusCode) { 434 v.newListPager.remove(req) 435 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} 436 } 437 if !server.PagerResponderMore(newListPager) { 438 v.newListPager.remove(req) 439 } 440 return resp, nil 441 } 442 443 func (v *VirtualHubsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { 444 if v.srv.NewListByResourceGroupPager == nil { 445 return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} 446 } 447 newListByResourceGroupPager := v.newListByResourceGroupPager.get(req) 448 if newListByResourceGroupPager == nil { 449 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs` 450 regex := regexp.MustCompile(regexStr) 451 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 452 if matches == nil || len(matches) < 2 { 453 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 454 } 455 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 456 if err != nil { 457 return nil, err 458 } 459 resp := v.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) 460 newListByResourceGroupPager = &resp 461 v.newListByResourceGroupPager.add(req, newListByResourceGroupPager) 462 server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armnetwork.VirtualHubsClientListByResourceGroupResponse, createLink func() string) { 463 page.NextLink = to.Ptr(createLink()) 464 }) 465 } 466 resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) 467 if err != nil { 468 return nil, err 469 } 470 if !contains([]int{http.StatusOK}, resp.StatusCode) { 471 v.newListByResourceGroupPager.remove(req) 472 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} 473 } 474 if !server.PagerResponderMore(newListByResourceGroupPager) { 475 v.newListByResourceGroupPager.remove(req) 476 } 477 return resp, nil 478 } 479 480 func (v *VirtualHubsServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { 481 if v.srv.UpdateTags == nil { 482 return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} 483 } 484 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/virtualHubs/(?P<virtualHubName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 485 regex := regexp.MustCompile(regexStr) 486 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 487 if matches == nil || len(matches) < 3 { 488 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 489 } 490 body, err := server.UnmarshalRequestAsJSON[armnetwork.TagsObject](req) 491 if err != nil { 492 return nil, err 493 } 494 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 495 if err != nil { 496 return nil, err 497 } 498 virtualHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualHubName")]) 499 if err != nil { 500 return nil, err 501 } 502 respr, errRespr := v.srv.UpdateTags(req.Context(), resourceGroupNameParam, virtualHubNameParam, body, nil) 503 if respErr := server.GetError(errRespr, req); respErr != nil { 504 return nil, respErr 505 } 506 respContent := server.GetResponseContent(respr) 507 if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { 508 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} 509 } 510 resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VirtualHub, req) 511 if err != nil { 512 return nil, err 513 } 514 return resp, nil 515 }