1package network
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"net/http"
25)
26
27// VirtualNetworkGatewayConnectionsClient is the network Client
28type VirtualNetworkGatewayConnectionsClient struct {
29	BaseClient
30}
31
32// NewVirtualNetworkGatewayConnectionsClient creates an instance of the VirtualNetworkGatewayConnectionsClient client.
33func NewVirtualNetworkGatewayConnectionsClient(subscriptionID string) VirtualNetworkGatewayConnectionsClient {
34	return NewVirtualNetworkGatewayConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
35}
36
37// NewVirtualNetworkGatewayConnectionsClientWithBaseURI creates an instance of the
38// VirtualNetworkGatewayConnectionsClient client.
39func NewVirtualNetworkGatewayConnectionsClientWithBaseURI(baseURI string, subscriptionID string) VirtualNetworkGatewayConnectionsClient {
40	return VirtualNetworkGatewayConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)}
41}
42
43// CreateOrUpdate the Put VirtualNetworkGatewayConnection operation creates/updates a virtual network gateway
44// connection in the specified resource group through Network resource provider.
45// Parameters:
46// resourceGroupName - the name of the resource group.
47// virtualNetworkGatewayConnectionName - the name of the virtual network gateway conenction.
48// parameters - parameters supplied to the Begin Create or update Virtual Network Gateway connection operation
49// through Network resource provider.
50func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection) (result VirtualNetworkGatewayConnectionsCreateOrUpdateFuture, err error) {
51	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters)
52	if err != nil {
53		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request")
54		return
55	}
56
57	result, err = client.CreateOrUpdateSender(req)
58	if err != nil {
59		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
60		return
61	}
62
63	return
64}
65
66// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
67func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection) (*http.Request, error) {
68	pathParameters := map[string]interface{}{
69		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
70		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
71		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
72	}
73
74	const APIVersion = "2016-03-30"
75	queryParameters := map[string]interface{}{
76		"api-version": APIVersion,
77	}
78
79	preparer := autorest.CreatePreparer(
80		autorest.AsContentType("application/json; charset=utf-8"),
81		autorest.AsPut(),
82		autorest.WithBaseURL(client.BaseURI),
83		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters),
84		autorest.WithJSON(parameters),
85		autorest.WithQueryParameters(queryParameters))
86	return preparer.Prepare((&http.Request{}).WithContext(ctx))
87}
88
89// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
90// http.Response Body if it receives an error.
91func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateSender(req *http.Request) (future VirtualNetworkGatewayConnectionsCreateOrUpdateFuture, err error) {
92	sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
93	future.Future = azure.NewFuture(req)
94	future.req = req
95	_, err = future.Done(sender)
96	if err != nil {
97		return
98	}
99	err = autorest.Respond(future.Response(),
100		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated))
101	return
102}
103
104// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
105// closes the http.Response Body.
106func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) {
107	err = autorest.Respond(
108		resp,
109		client.ByInspecting(),
110		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
111		autorest.ByUnmarshallingJSON(&result),
112		autorest.ByClosing())
113	result.Response = autorest.Response{Response: resp}
114	return
115}
116
117// Delete the Delete VirtualNetworkGatewayConnection operation deletes the specifed virtual network Gateway connection
118// through Network resource provider.
119// Parameters:
120// resourceGroupName - the name of the resource group.
121// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection.
122func (client VirtualNetworkGatewayConnectionsClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnectionsDeleteFuture, err error) {
123	req, err := client.DeletePreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName)
124	if err != nil {
125		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request")
126		return
127	}
128
129	result, err = client.DeleteSender(req)
130	if err != nil {
131		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", result.Response(), "Failure sending request")
132		return
133	}
134
135	return
136}
137
138// DeletePreparer prepares the Delete request.
139func (client VirtualNetworkGatewayConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) {
140	pathParameters := map[string]interface{}{
141		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
142		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
143		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
144	}
145
146	const APIVersion = "2016-03-30"
147	queryParameters := map[string]interface{}{
148		"api-version": APIVersion,
149	}
150
151	preparer := autorest.CreatePreparer(
152		autorest.AsDelete(),
153		autorest.WithBaseURL(client.BaseURI),
154		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters),
155		autorest.WithQueryParameters(queryParameters))
156	return preparer.Prepare((&http.Request{}).WithContext(ctx))
157}
158
159// DeleteSender sends the Delete request. The method will close the
160// http.Response Body if it receives an error.
161func (client VirtualNetworkGatewayConnectionsClient) DeleteSender(req *http.Request) (future VirtualNetworkGatewayConnectionsDeleteFuture, err error) {
162	sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
163	future.Future = azure.NewFuture(req)
164	future.req = req
165	_, err = future.Done(sender)
166	if err != nil {
167		return
168	}
169	err = autorest.Respond(future.Response(),
170		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
171	return
172}
173
174// DeleteResponder handles the response to the Delete request. The method always
175// closes the http.Response Body.
176func (client VirtualNetworkGatewayConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
177	err = autorest.Respond(
178		resp,
179		client.ByInspecting(),
180		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
181		autorest.ByClosing())
182	result.Response = resp
183	return
184}
185
186// Get the Get VirtualNetworkGatewayConnection operation retrieves information about the specified virtual network
187// gateway connection through Network resource provider.
188// Parameters:
189// resourceGroupName - the name of the resource group.
190// virtualNetworkGatewayConnectionName - the name of the virtual network gateway connection.
191func (client VirtualNetworkGatewayConnectionsClient) Get(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnection, err error) {
192	req, err := client.GetPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName)
193	if err != nil {
194		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request")
195		return
196	}
197
198	resp, err := client.GetSender(req)
199	if err != nil {
200		result.Response = autorest.Response{Response: resp}
201		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request")
202		return
203	}
204
205	result, err = client.GetResponder(resp)
206	if err != nil {
207		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure responding to request")
208	}
209
210	return
211}
212
213// GetPreparer prepares the Get request.
214func (client VirtualNetworkGatewayConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) {
215	pathParameters := map[string]interface{}{
216		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
217		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
218		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
219	}
220
221	const APIVersion = "2016-03-30"
222	queryParameters := map[string]interface{}{
223		"api-version": APIVersion,
224	}
225
226	preparer := autorest.CreatePreparer(
227		autorest.AsGet(),
228		autorest.WithBaseURL(client.BaseURI),
229		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters),
230		autorest.WithQueryParameters(queryParameters))
231	return preparer.Prepare((&http.Request{}).WithContext(ctx))
232}
233
234// GetSender sends the Get request. The method will close the
235// http.Response Body if it receives an error.
236func (client VirtualNetworkGatewayConnectionsClient) GetSender(req *http.Request) (*http.Response, error) {
237	return autorest.SendWithSender(client, req,
238		azure.DoRetryWithRegistration(client.Client))
239}
240
241// GetResponder handles the response to the Get request. The method always
242// closes the http.Response Body.
243func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) {
244	err = autorest.Respond(
245		resp,
246		client.ByInspecting(),
247		azure.WithErrorUnlessStatusCode(http.StatusOK),
248		autorest.ByUnmarshallingJSON(&result),
249		autorest.ByClosing())
250	result.Response = autorest.Response{Response: resp}
251	return
252}
253
254// GetSharedKey the Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified
255// virtual network gateway connection shared key through Network resource provider.
256// Parameters:
257// resourceGroupName - the name of the resource group.
258// connectionSharedKeyName - the virtual network gateway connection shared key name.
259func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(ctx context.Context, resourceGroupName string, connectionSharedKeyName string) (result ConnectionSharedKeyResult, err error) {
260	req, err := client.GetSharedKeyPreparer(ctx, resourceGroupName, connectionSharedKeyName)
261	if err != nil {
262		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request")
263		return
264	}
265
266	resp, err := client.GetSharedKeySender(req)
267	if err != nil {
268		result.Response = autorest.Response{Response: resp}
269		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request")
270		return
271	}
272
273	result, err = client.GetSharedKeyResponder(resp)
274	if err != nil {
275		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure responding to request")
276	}
277
278	return
279}
280
281// GetSharedKeyPreparer prepares the GetSharedKey request.
282func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyPreparer(ctx context.Context, resourceGroupName string, connectionSharedKeyName string) (*http.Request, error) {
283	pathParameters := map[string]interface{}{
284		"connectionSharedKeyName": autorest.Encode("path", connectionSharedKeyName),
285		"resourceGroupName":       autorest.Encode("path", resourceGroupName),
286		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
287	}
288
289	const APIVersion = "2016-03-30"
290	queryParameters := map[string]interface{}{
291		"api-version": APIVersion,
292	}
293
294	preparer := autorest.CreatePreparer(
295		autorest.AsGet(),
296		autorest.WithBaseURL(client.BaseURI),
297		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{connectionSharedKeyName}/sharedkey", pathParameters),
298		autorest.WithQueryParameters(queryParameters))
299	return preparer.Prepare((&http.Request{}).WithContext(ctx))
300}
301
302// GetSharedKeySender sends the GetSharedKey request. The method will close the
303// http.Response Body if it receives an error.
304func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeySender(req *http.Request) (*http.Response, error) {
305	return autorest.SendWithSender(client, req,
306		azure.DoRetryWithRegistration(client.Client))
307}
308
309// GetSharedKeyResponder handles the response to the GetSharedKey request. The method always
310// closes the http.Response Body.
311func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKeyResult, err error) {
312	err = autorest.Respond(
313		resp,
314		client.ByInspecting(),
315		azure.WithErrorUnlessStatusCode(http.StatusOK),
316		autorest.ByUnmarshallingJSON(&result),
317		autorest.ByClosing())
318	result.Response = autorest.Response{Response: resp}
319	return
320}
321
322// List the List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections
323// created.
324// Parameters:
325// resourceGroupName - the name of the resource group.
326func (client VirtualNetworkGatewayConnectionsClient) List(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayConnectionListResultPage, err error) {
327	result.fn = client.listNextResults
328	req, err := client.ListPreparer(ctx, resourceGroupName)
329	if err != nil {
330		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request")
331		return
332	}
333
334	resp, err := client.ListSender(req)
335	if err != nil {
336		result.vngclr.Response = autorest.Response{Response: resp}
337		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request")
338		return
339	}
340
341	result.vngclr, err = client.ListResponder(resp)
342	if err != nil {
343		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure responding to request")
344	}
345
346	return
347}
348
349// ListPreparer prepares the List request.
350func (client VirtualNetworkGatewayConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
351	pathParameters := map[string]interface{}{
352		"resourceGroupName": autorest.Encode("path", resourceGroupName),
353		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
354	}
355
356	const APIVersion = "2016-03-30"
357	queryParameters := map[string]interface{}{
358		"api-version": APIVersion,
359	}
360
361	preparer := autorest.CreatePreparer(
362		autorest.AsGet(),
363		autorest.WithBaseURL(client.BaseURI),
364		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections", pathParameters),
365		autorest.WithQueryParameters(queryParameters))
366	return preparer.Prepare((&http.Request{}).WithContext(ctx))
367}
368
369// ListSender sends the List request. The method will close the
370// http.Response Body if it receives an error.
371func (client VirtualNetworkGatewayConnectionsClient) ListSender(req *http.Request) (*http.Response, error) {
372	return autorest.SendWithSender(client, req,
373		azure.DoRetryWithRegistration(client.Client))
374}
375
376// ListResponder handles the response to the List request. The method always
377// closes the http.Response Body.
378func (client VirtualNetworkGatewayConnectionsClient) ListResponder(resp *http.Response) (result VirtualNetworkGatewayConnectionListResult, err error) {
379	err = autorest.Respond(
380		resp,
381		client.ByInspecting(),
382		azure.WithErrorUnlessStatusCode(http.StatusOK),
383		autorest.ByUnmarshallingJSON(&result),
384		autorest.ByClosing())
385	result.Response = autorest.Response{Response: resp}
386	return
387}
388
389// listNextResults retrieves the next set of results, if any.
390func (client VirtualNetworkGatewayConnectionsClient) listNextResults(lastResults VirtualNetworkGatewayConnectionListResult) (result VirtualNetworkGatewayConnectionListResult, err error) {
391	req, err := lastResults.virtualNetworkGatewayConnectionListResultPreparer()
392	if err != nil {
393		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", nil, "Failure preparing next results request")
394	}
395	if req == nil {
396		return
397	}
398	resp, err := client.ListSender(req)
399	if err != nil {
400		result.Response = autorest.Response{Response: resp}
401		return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", resp, "Failure sending next results request")
402	}
403	result, err = client.ListResponder(resp)
404	if err != nil {
405		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "listNextResults", resp, "Failure responding to next results request")
406	}
407	return
408}
409
410// ListComplete enumerates all values, automatically crossing page boundaries as required.
411func (client VirtualNetworkGatewayConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string) (result VirtualNetworkGatewayConnectionListResultIterator, err error) {
412	result.page, err = client.List(ctx, resourceGroupName)
413	return
414}
415
416// ResetSharedKey the VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway
417// connection shared key for passed virtual network gateway connection in the specified resource group through Network
418// resource provider.
419// Parameters:
420// resourceGroupName - the name of the resource group.
421// virtualNetworkGatewayConnectionName - the virtual network gateway connection reset shared key Name.
422// parameters - parameters supplied to the Begin Reset Virtual Network Gateway connection shared key operation
423// through Network resource provider.
424func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey) (result VirtualNetworkGatewayConnectionsResetSharedKeyFuture, err error) {
425	req, err := client.ResetSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters)
426	if err != nil {
427		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request")
428		return
429	}
430
431	result, err = client.ResetSharedKeySender(req)
432	if err != nil {
433		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", result.Response(), "Failure sending request")
434		return
435	}
436
437	return
438}
439
440// ResetSharedKeyPreparer prepares the ResetSharedKey request.
441func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey) (*http.Request, error) {
442	pathParameters := map[string]interface{}{
443		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
444		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
445		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
446	}
447
448	const APIVersion = "2016-03-30"
449	queryParameters := map[string]interface{}{
450		"api-version": APIVersion,
451	}
452
453	preparer := autorest.CreatePreparer(
454		autorest.AsContentType("application/json; charset=utf-8"),
455		autorest.AsPost(),
456		autorest.WithBaseURL(client.BaseURI),
457		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey/reset", pathParameters),
458		autorest.WithJSON(parameters),
459		autorest.WithQueryParameters(queryParameters))
460	return preparer.Prepare((&http.Request{}).WithContext(ctx))
461}
462
463// ResetSharedKeySender sends the ResetSharedKey request. The method will close the
464// http.Response Body if it receives an error.
465func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeySender(req *http.Request) (future VirtualNetworkGatewayConnectionsResetSharedKeyFuture, err error) {
466	sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
467	future.Future = azure.NewFuture(req)
468	future.req = req
469	_, err = future.Done(sender)
470	if err != nil {
471		return
472	}
473	err = autorest.Respond(future.Response(),
474		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
475	return
476}
477
478// ResetSharedKeyResponder handles the response to the ResetSharedKey request. The method always
479// closes the http.Response Body.
480func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result ConnectionResetSharedKey, err error) {
481	err = autorest.Respond(
482		resp,
483		client.ByInspecting(),
484		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
485		autorest.ByUnmarshallingJSON(&result),
486		autorest.ByClosing())
487	result.Response = autorest.Response{Response: resp}
488	return
489}
490
491// SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection
492// shared key for passed virtual network gateway connection in the specified resource group through Network resource
493// provider.
494// Parameters:
495// resourceGroupName - the name of the resource group.
496// virtualNetworkGatewayConnectionName - the virtual network gateway connection name.
497// parameters - parameters supplied to the Begin Set Virtual Network Gateway conection Shared key operation
498// throughNetwork resource provider.
499func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey) (result VirtualNetworkGatewayConnectionsSetSharedKeyFuture, err error) {
500	req, err := client.SetSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayConnectionName, parameters)
501	if err != nil {
502		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request")
503		return
504	}
505
506	result, err = client.SetSharedKeySender(req)
507	if err != nil {
508		err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", result.Response(), "Failure sending request")
509		return
510	}
511
512	return
513}
514
515// SetSharedKeyPreparer prepares the SetSharedKey request.
516func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey) (*http.Request, error) {
517	pathParameters := map[string]interface{}{
518		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
519		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
520		"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
521	}
522
523	const APIVersion = "2016-03-30"
524	queryParameters := map[string]interface{}{
525		"api-version": APIVersion,
526	}
527
528	preparer := autorest.CreatePreparer(
529		autorest.AsContentType("application/json; charset=utf-8"),
530		autorest.AsPut(),
531		autorest.WithBaseURL(client.BaseURI),
532		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey", pathParameters),
533		autorest.WithJSON(parameters),
534		autorest.WithQueryParameters(queryParameters))
535	return preparer.Prepare((&http.Request{}).WithContext(ctx))
536}
537
538// SetSharedKeySender sends the SetSharedKey request. The method will close the
539// http.Response Body if it receives an error.
540func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeySender(req *http.Request) (future VirtualNetworkGatewayConnectionsSetSharedKeyFuture, err error) {
541	sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
542	future.Future = azure.NewFuture(req)
543	future.req = req
544	_, err = future.Done(sender)
545	if err != nil {
546		return
547	}
548	err = autorest.Respond(future.Response(),
549		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated))
550	return
551}
552
553// SetSharedKeyResponder handles the response to the SetSharedKey request. The method always
554// closes the http.Response Body.
555func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKey, err error) {
556	err = autorest.Respond(
557		resp,
558		client.ByInspecting(),
559		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
560		autorest.ByUnmarshallingJSON(&result),
561		autorest.ByClosing())
562	result.Response = autorest.Response{Response: resp}
563	return
564}
565