github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6@v6.2.0/fake/expressroutecrossconnections_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 "regexp" 23 ) 24 25 // ExpressRouteCrossConnectionsServer is a fake server for instances of the armnetwork.ExpressRouteCrossConnectionsClient type. 26 type ExpressRouteCrossConnectionsServer struct { 27 // BeginCreateOrUpdate is the fake for method ExpressRouteCrossConnectionsClient.BeginCreateOrUpdate 28 // HTTP status codes to indicate success: http.StatusOK 29 BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, crossConnectionName string, parameters armnetwork.ExpressRouteCrossConnection, options *armnetwork.ExpressRouteCrossConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) 30 31 // Get is the fake for method ExpressRouteCrossConnectionsClient.Get 32 // HTTP status codes to indicate success: http.StatusOK 33 Get func(ctx context.Context, resourceGroupName string, crossConnectionName string, options *armnetwork.ExpressRouteCrossConnectionsClientGetOptions) (resp azfake.Responder[armnetwork.ExpressRouteCrossConnectionsClientGetResponse], errResp azfake.ErrorResponder) 34 35 // NewListPager is the fake for method ExpressRouteCrossConnectionsClient.NewListPager 36 // HTTP status codes to indicate success: http.StatusOK 37 NewListPager func(options *armnetwork.ExpressRouteCrossConnectionsClientListOptions) (resp azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListResponse]) 38 39 // BeginListArpTable is the fake for method ExpressRouteCrossConnectionsClient.BeginListArpTable 40 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 41 BeginListArpTable func(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *armnetwork.ExpressRouteCrossConnectionsClientBeginListArpTableOptions) (resp azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListArpTableResponse], errResp azfake.ErrorResponder) 42 43 // NewListByResourceGroupPager is the fake for method ExpressRouteCrossConnectionsClient.NewListByResourceGroupPager 44 // HTTP status codes to indicate success: http.StatusOK 45 NewListByResourceGroupPager func(resourceGroupName string, options *armnetwork.ExpressRouteCrossConnectionsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListByResourceGroupResponse]) 46 47 // BeginListRoutesTable is the fake for method ExpressRouteCrossConnectionsClient.BeginListRoutesTable 48 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 49 BeginListRoutesTable func(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *armnetwork.ExpressRouteCrossConnectionsClientBeginListRoutesTableOptions) (resp azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableResponse], errResp azfake.ErrorResponder) 50 51 // BeginListRoutesTableSummary is the fake for method ExpressRouteCrossConnectionsClient.BeginListRoutesTableSummary 52 // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted 53 BeginListRoutesTableSummary func(ctx context.Context, resourceGroupName string, crossConnectionName string, peeringName string, devicePath string, options *armnetwork.ExpressRouteCrossConnectionsClientBeginListRoutesTableSummaryOptions) (resp azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse], errResp azfake.ErrorResponder) 54 55 // UpdateTags is the fake for method ExpressRouteCrossConnectionsClient.UpdateTags 56 // HTTP status codes to indicate success: http.StatusOK 57 UpdateTags func(ctx context.Context, resourceGroupName string, crossConnectionName string, crossConnectionParameters armnetwork.TagsObject, options *armnetwork.ExpressRouteCrossConnectionsClientUpdateTagsOptions) (resp azfake.Responder[armnetwork.ExpressRouteCrossConnectionsClientUpdateTagsResponse], errResp azfake.ErrorResponder) 58 } 59 60 // NewExpressRouteCrossConnectionsServerTransport creates a new instance of ExpressRouteCrossConnectionsServerTransport with the provided implementation. 61 // The returned ExpressRouteCrossConnectionsServerTransport instance is connected to an instance of armnetwork.ExpressRouteCrossConnectionsClient via the 62 // azcore.ClientOptions.Transporter field in the client's constructor parameters. 63 func NewExpressRouteCrossConnectionsServerTransport(srv *ExpressRouteCrossConnectionsServer) *ExpressRouteCrossConnectionsServerTransport { 64 return &ExpressRouteCrossConnectionsServerTransport{ 65 srv: srv, 66 beginCreateOrUpdate: newTracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientCreateOrUpdateResponse]](), 67 newListPager: newTracker[azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListResponse]](), 68 beginListArpTable: newTracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListArpTableResponse]](), 69 newListByResourceGroupPager: newTracker[azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListByResourceGroupResponse]](), 70 beginListRoutesTable: newTracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableResponse]](), 71 beginListRoutesTableSummary: newTracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse]](), 72 } 73 } 74 75 // ExpressRouteCrossConnectionsServerTransport connects instances of armnetwork.ExpressRouteCrossConnectionsClient to instances of ExpressRouteCrossConnectionsServer. 76 // Don't use this type directly, use NewExpressRouteCrossConnectionsServerTransport instead. 77 type ExpressRouteCrossConnectionsServerTransport struct { 78 srv *ExpressRouteCrossConnectionsServer 79 beginCreateOrUpdate *tracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientCreateOrUpdateResponse]] 80 newListPager *tracker[azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListResponse]] 81 beginListArpTable *tracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListArpTableResponse]] 82 newListByResourceGroupPager *tracker[azfake.PagerResponder[armnetwork.ExpressRouteCrossConnectionsClientListByResourceGroupResponse]] 83 beginListRoutesTable *tracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableResponse]] 84 beginListRoutesTableSummary *tracker[azfake.PollerResponder[armnetwork.ExpressRouteCrossConnectionsClientListRoutesTableSummaryResponse]] 85 } 86 87 // Do implements the policy.Transporter interface for ExpressRouteCrossConnectionsServerTransport. 88 func (e *ExpressRouteCrossConnectionsServerTransport) Do(req *http.Request) (*http.Response, error) { 89 rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) 90 method, ok := rawMethod.(string) 91 if !ok { 92 return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} 93 } 94 95 var resp *http.Response 96 var err error 97 98 switch method { 99 case "ExpressRouteCrossConnectionsClient.BeginCreateOrUpdate": 100 resp, err = e.dispatchBeginCreateOrUpdate(req) 101 case "ExpressRouteCrossConnectionsClient.Get": 102 resp, err = e.dispatchGet(req) 103 case "ExpressRouteCrossConnectionsClient.NewListPager": 104 resp, err = e.dispatchNewListPager(req) 105 case "ExpressRouteCrossConnectionsClient.BeginListArpTable": 106 resp, err = e.dispatchBeginListArpTable(req) 107 case "ExpressRouteCrossConnectionsClient.NewListByResourceGroupPager": 108 resp, err = e.dispatchNewListByResourceGroupPager(req) 109 case "ExpressRouteCrossConnectionsClient.BeginListRoutesTable": 110 resp, err = e.dispatchBeginListRoutesTable(req) 111 case "ExpressRouteCrossConnectionsClient.BeginListRoutesTableSummary": 112 resp, err = e.dispatchBeginListRoutesTableSummary(req) 113 case "ExpressRouteCrossConnectionsClient.UpdateTags": 114 resp, err = e.dispatchUpdateTags(req) 115 default: 116 err = fmt.Errorf("unhandled API %s", method) 117 } 118 119 if err != nil { 120 return nil, err 121 } 122 123 return resp, nil 124 } 125 126 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { 127 if e.srv.BeginCreateOrUpdate == nil { 128 return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} 129 } 130 beginCreateOrUpdate := e.beginCreateOrUpdate.get(req) 131 if beginCreateOrUpdate == nil { 132 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 133 regex := regexp.MustCompile(regexStr) 134 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 135 if matches == nil || len(matches) < 3 { 136 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 137 } 138 body, err := server.UnmarshalRequestAsJSON[armnetwork.ExpressRouteCrossConnection](req) 139 if err != nil { 140 return nil, err 141 } 142 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 143 if err != nil { 144 return nil, err 145 } 146 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 147 if err != nil { 148 return nil, err 149 } 150 respr, errRespr := e.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, crossConnectionNameParam, body, nil) 151 if respErr := server.GetError(errRespr, req); respErr != nil { 152 return nil, respErr 153 } 154 beginCreateOrUpdate = &respr 155 e.beginCreateOrUpdate.add(req, beginCreateOrUpdate) 156 } 157 158 resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) 159 if err != nil { 160 return nil, err 161 } 162 163 if !contains([]int{http.StatusOK}, resp.StatusCode) { 164 e.beginCreateOrUpdate.remove(req) 165 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} 166 } 167 if !server.PollerResponderMore(beginCreateOrUpdate) { 168 e.beginCreateOrUpdate.remove(req) 169 } 170 171 return resp, nil 172 } 173 174 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { 175 if e.srv.Get == nil { 176 return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} 177 } 178 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 179 regex := regexp.MustCompile(regexStr) 180 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 181 if matches == nil || len(matches) < 3 { 182 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 183 } 184 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 185 if err != nil { 186 return nil, err 187 } 188 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 189 if err != nil { 190 return nil, err 191 } 192 respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, crossConnectionNameParam, nil) 193 if respErr := server.GetError(errRespr, req); respErr != nil { 194 return nil, respErr 195 } 196 respContent := server.GetResponseContent(respr) 197 if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { 198 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} 199 } 200 resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ExpressRouteCrossConnection, req) 201 if err != nil { 202 return nil, err 203 } 204 return resp, nil 205 } 206 207 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { 208 if e.srv.NewListPager == nil { 209 return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} 210 } 211 newListPager := e.newListPager.get(req) 212 if newListPager == nil { 213 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections` 214 regex := regexp.MustCompile(regexStr) 215 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 216 if matches == nil || len(matches) < 1 { 217 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 218 } 219 qp := req.URL.Query() 220 filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) 221 if err != nil { 222 return nil, err 223 } 224 filterParam := getOptional(filterUnescaped) 225 var options *armnetwork.ExpressRouteCrossConnectionsClientListOptions 226 if filterParam != nil { 227 options = &armnetwork.ExpressRouteCrossConnectionsClientListOptions{ 228 Filter: filterParam, 229 } 230 } 231 resp := e.srv.NewListPager(options) 232 newListPager = &resp 233 e.newListPager.add(req, newListPager) 234 server.PagerResponderInjectNextLinks(newListPager, req, func(page *armnetwork.ExpressRouteCrossConnectionsClientListResponse, createLink func() string) { 235 page.NextLink = to.Ptr(createLink()) 236 }) 237 } 238 resp, err := server.PagerResponderNext(newListPager, req) 239 if err != nil { 240 return nil, err 241 } 242 if !contains([]int{http.StatusOK}, resp.StatusCode) { 243 e.newListPager.remove(req) 244 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} 245 } 246 if !server.PagerResponderMore(newListPager) { 247 e.newListPager.remove(req) 248 } 249 return resp, nil 250 } 251 252 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchBeginListArpTable(req *http.Request) (*http.Response, error) { 253 if e.srv.BeginListArpTable == nil { 254 return nil, &nonRetriableError{errors.New("fake for method BeginListArpTable not implemented")} 255 } 256 beginListArpTable := e.beginListArpTable.get(req) 257 if beginListArpTable == nil { 258 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/peerings/(?P<peeringName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/arpTables/(?P<devicePath>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 259 regex := regexp.MustCompile(regexStr) 260 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 261 if matches == nil || len(matches) < 5 { 262 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 263 } 264 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 265 if err != nil { 266 return nil, err 267 } 268 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 269 if err != nil { 270 return nil, err 271 } 272 peeringNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("peeringName")]) 273 if err != nil { 274 return nil, err 275 } 276 devicePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("devicePath")]) 277 if err != nil { 278 return nil, err 279 } 280 respr, errRespr := e.srv.BeginListArpTable(req.Context(), resourceGroupNameParam, crossConnectionNameParam, peeringNameParam, devicePathParam, nil) 281 if respErr := server.GetError(errRespr, req); respErr != nil { 282 return nil, respErr 283 } 284 beginListArpTable = &respr 285 e.beginListArpTable.add(req, beginListArpTable) 286 } 287 288 resp, err := server.PollerResponderNext(beginListArpTable, req) 289 if err != nil { 290 return nil, err 291 } 292 293 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 294 e.beginListArpTable.remove(req) 295 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 296 } 297 if !server.PollerResponderMore(beginListArpTable) { 298 e.beginListArpTable.remove(req) 299 } 300 301 return resp, nil 302 } 303 304 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { 305 if e.srv.NewListByResourceGroupPager == nil { 306 return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} 307 } 308 newListByResourceGroupPager := e.newListByResourceGroupPager.get(req) 309 if newListByResourceGroupPager == nil { 310 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections` 311 regex := regexp.MustCompile(regexStr) 312 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 313 if matches == nil || len(matches) < 2 { 314 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 315 } 316 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 317 if err != nil { 318 return nil, err 319 } 320 resp := e.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) 321 newListByResourceGroupPager = &resp 322 e.newListByResourceGroupPager.add(req, newListByResourceGroupPager) 323 server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armnetwork.ExpressRouteCrossConnectionsClientListByResourceGroupResponse, createLink func() string) { 324 page.NextLink = to.Ptr(createLink()) 325 }) 326 } 327 resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) 328 if err != nil { 329 return nil, err 330 } 331 if !contains([]int{http.StatusOK}, resp.StatusCode) { 332 e.newListByResourceGroupPager.remove(req) 333 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} 334 } 335 if !server.PagerResponderMore(newListByResourceGroupPager) { 336 e.newListByResourceGroupPager.remove(req) 337 } 338 return resp, nil 339 } 340 341 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchBeginListRoutesTable(req *http.Request) (*http.Response, error) { 342 if e.srv.BeginListRoutesTable == nil { 343 return nil, &nonRetriableError{errors.New("fake for method BeginListRoutesTable not implemented")} 344 } 345 beginListRoutesTable := e.beginListRoutesTable.get(req) 346 if beginListRoutesTable == nil { 347 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/peerings/(?P<peeringName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/routeTables/(?P<devicePath>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 348 regex := regexp.MustCompile(regexStr) 349 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 350 if matches == nil || len(matches) < 5 { 351 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 352 } 353 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 354 if err != nil { 355 return nil, err 356 } 357 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 358 if err != nil { 359 return nil, err 360 } 361 peeringNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("peeringName")]) 362 if err != nil { 363 return nil, err 364 } 365 devicePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("devicePath")]) 366 if err != nil { 367 return nil, err 368 } 369 respr, errRespr := e.srv.BeginListRoutesTable(req.Context(), resourceGroupNameParam, crossConnectionNameParam, peeringNameParam, devicePathParam, nil) 370 if respErr := server.GetError(errRespr, req); respErr != nil { 371 return nil, respErr 372 } 373 beginListRoutesTable = &respr 374 e.beginListRoutesTable.add(req, beginListRoutesTable) 375 } 376 377 resp, err := server.PollerResponderNext(beginListRoutesTable, req) 378 if err != nil { 379 return nil, err 380 } 381 382 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 383 e.beginListRoutesTable.remove(req) 384 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 385 } 386 if !server.PollerResponderMore(beginListRoutesTable) { 387 e.beginListRoutesTable.remove(req) 388 } 389 390 return resp, nil 391 } 392 393 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchBeginListRoutesTableSummary(req *http.Request) (*http.Response, error) { 394 if e.srv.BeginListRoutesTableSummary == nil { 395 return nil, &nonRetriableError{errors.New("fake for method BeginListRoutesTableSummary not implemented")} 396 } 397 beginListRoutesTableSummary := e.beginListRoutesTableSummary.get(req) 398 if beginListRoutesTableSummary == nil { 399 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/peerings/(?P<peeringName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/routeTablesSummary/(?P<devicePath>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 400 regex := regexp.MustCompile(regexStr) 401 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 402 if matches == nil || len(matches) < 5 { 403 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 404 } 405 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 406 if err != nil { 407 return nil, err 408 } 409 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 410 if err != nil { 411 return nil, err 412 } 413 peeringNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("peeringName")]) 414 if err != nil { 415 return nil, err 416 } 417 devicePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("devicePath")]) 418 if err != nil { 419 return nil, err 420 } 421 respr, errRespr := e.srv.BeginListRoutesTableSummary(req.Context(), resourceGroupNameParam, crossConnectionNameParam, peeringNameParam, devicePathParam, nil) 422 if respErr := server.GetError(errRespr, req); respErr != nil { 423 return nil, respErr 424 } 425 beginListRoutesTableSummary = &respr 426 e.beginListRoutesTableSummary.add(req, beginListRoutesTableSummary) 427 } 428 429 resp, err := server.PollerResponderNext(beginListRoutesTableSummary, req) 430 if err != nil { 431 return nil, err 432 } 433 434 if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { 435 e.beginListRoutesTableSummary.remove(req) 436 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} 437 } 438 if !server.PollerResponderMore(beginListRoutesTableSummary) { 439 e.beginListRoutesTableSummary.remove(req) 440 } 441 442 return resp, nil 443 } 444 445 func (e *ExpressRouteCrossConnectionsServerTransport) dispatchUpdateTags(req *http.Request) (*http.Response, error) { 446 if e.srv.UpdateTags == nil { 447 return nil, &nonRetriableError{errors.New("fake for method UpdateTags not implemented")} 448 } 449 const regexStr = `/subscriptions/(?P<subscriptionId>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P<resourceGroupName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Network/expressRouteCrossConnections/(?P<crossConnectionName>[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` 450 regex := regexp.MustCompile(regexStr) 451 matches := regex.FindStringSubmatch(req.URL.EscapedPath()) 452 if matches == nil || len(matches) < 3 { 453 return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) 454 } 455 body, err := server.UnmarshalRequestAsJSON[armnetwork.TagsObject](req) 456 if err != nil { 457 return nil, err 458 } 459 resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) 460 if err != nil { 461 return nil, err 462 } 463 crossConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("crossConnectionName")]) 464 if err != nil { 465 return nil, err 466 } 467 respr, errRespr := e.srv.UpdateTags(req.Context(), resourceGroupNameParam, crossConnectionNameParam, body, nil) 468 if respErr := server.GetError(errRespr, req); respErr != nil { 469 return nil, respErr 470 } 471 respContent := server.GetResponseContent(respr) 472 if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { 473 return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} 474 } 475 resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ExpressRouteCrossConnection, req) 476 if err != nil { 477 return nil, err 478 } 479 return resp, nil 480 }