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