1package blockchain
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	"github.com/Azure/go-autorest/tracing"
25	"net/http"
26)
27
28// TransactionNodesClient is the REST API for Azure Blockchain Service
29type TransactionNodesClient struct {
30	BaseClient
31}
32
33// NewTransactionNodesClient creates an instance of the TransactionNodesClient client.
34func NewTransactionNodesClient(subscriptionID string) TransactionNodesClient {
35	return NewTransactionNodesClientWithBaseURI(DefaultBaseURI, subscriptionID)
36}
37
38// NewTransactionNodesClientWithBaseURI creates an instance of the TransactionNodesClient client using a custom
39// endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
40// stack).
41func NewTransactionNodesClientWithBaseURI(baseURI string, subscriptionID string) TransactionNodesClient {
42	return TransactionNodesClient{NewWithBaseURI(baseURI, subscriptionID)}
43}
44
45// Create create or update the transaction node.
46// Parameters:
47// blockchainMemberName - blockchain member name.
48// transactionNodeName - transaction node name.
49// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
50// from the Azure Resource Manager API or the portal.
51// transactionNode - payload to create the transaction node.
52func (client TransactionNodesClient) Create(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, transactionNode *TransactionNode) (result TransactionNodesCreateFuture, err error) {
53	if tracing.IsEnabled() {
54		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.Create")
55		defer func() {
56			sc := -1
57			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
58				sc = result.FutureAPI.Response().StatusCode
59			}
60			tracing.EndSpan(ctx, sc, err)
61		}()
62	}
63	req, err := client.CreatePreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, transactionNode)
64	if err != nil {
65		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Create", nil, "Failure preparing request")
66		return
67	}
68
69	result, err = client.CreateSender(req)
70	if err != nil {
71		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Create", nil, "Failure sending request")
72		return
73	}
74
75	return
76}
77
78// CreatePreparer prepares the Create request.
79func (client TransactionNodesClient) CreatePreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, transactionNode *TransactionNode) (*http.Request, error) {
80	pathParameters := map[string]interface{}{
81		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
82		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
83		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
84		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
85	}
86
87	const APIVersion = "2018-06-01-preview"
88	queryParameters := map[string]interface{}{
89		"api-version": APIVersion,
90	}
91
92	preparer := autorest.CreatePreparer(
93		autorest.AsContentType("application/json; charset=utf-8"),
94		autorest.AsPut(),
95		autorest.WithBaseURL(client.BaseURI),
96		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}", pathParameters),
97		autorest.WithQueryParameters(queryParameters))
98	if transactionNode != nil {
99		preparer = autorest.DecoratePreparer(preparer,
100			autorest.WithJSON(transactionNode))
101	}
102	return preparer.Prepare((&http.Request{}).WithContext(ctx))
103}
104
105// CreateSender sends the Create request. The method will close the
106// http.Response Body if it receives an error.
107func (client TransactionNodesClient) CreateSender(req *http.Request) (future TransactionNodesCreateFuture, err error) {
108	var resp *http.Response
109	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
110	if err != nil {
111		return
112	}
113	var azf azure.Future
114	azf, err = azure.NewFutureFromResponse(resp)
115	future.FutureAPI = &azf
116	future.Result = func(client TransactionNodesClient) (tn TransactionNode, err error) {
117		var done bool
118		done, err = future.DoneWithContext(context.Background(), client)
119		if err != nil {
120			err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesCreateFuture", "Result", future.Response(), "Polling failure")
121			return
122		}
123		if !done {
124			err = azure.NewAsyncOpIncompleteError("blockchain.TransactionNodesCreateFuture")
125			return
126		}
127		sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
128		tn.Response.Response, err = future.GetResult(sender)
129		if tn.Response.Response == nil && err == nil {
130			err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesCreateFuture", "Result", nil, "received nil response and error")
131		}
132		if err == nil && tn.Response.Response.StatusCode != http.StatusNoContent {
133			tn, err = client.CreateResponder(tn.Response.Response)
134			if err != nil {
135				err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesCreateFuture", "Result", tn.Response.Response, "Failure responding to request")
136			}
137		}
138		return
139	}
140	return
141}
142
143// CreateResponder handles the response to the Create request. The method always
144// closes the http.Response Body.
145func (client TransactionNodesClient) CreateResponder(resp *http.Response) (result TransactionNode, err error) {
146	err = autorest.Respond(
147		resp,
148		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
149		autorest.ByUnmarshallingJSON(&result),
150		autorest.ByClosing())
151	result.Response = autorest.Response{Response: resp}
152	return
153}
154
155// Delete delete the transaction node.
156// Parameters:
157// blockchainMemberName - blockchain member name.
158// transactionNodeName - transaction node name.
159// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
160// from the Azure Resource Manager API or the portal.
161func (client TransactionNodesClient) Delete(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (result TransactionNodesDeleteFuture, err error) {
162	if tracing.IsEnabled() {
163		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.Delete")
164		defer func() {
165			sc := -1
166			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
167				sc = result.FutureAPI.Response().StatusCode
168			}
169			tracing.EndSpan(ctx, sc, err)
170		}()
171	}
172	req, err := client.DeletePreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName)
173	if err != nil {
174		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Delete", nil, "Failure preparing request")
175		return
176	}
177
178	result, err = client.DeleteSender(req)
179	if err != nil {
180		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Delete", nil, "Failure sending request")
181		return
182	}
183
184	return
185}
186
187// DeletePreparer prepares the Delete request.
188func (client TransactionNodesClient) DeletePreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (*http.Request, error) {
189	pathParameters := map[string]interface{}{
190		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
191		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
192		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
193		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
194	}
195
196	const APIVersion = "2018-06-01-preview"
197	queryParameters := map[string]interface{}{
198		"api-version": APIVersion,
199	}
200
201	preparer := autorest.CreatePreparer(
202		autorest.AsDelete(),
203		autorest.WithBaseURL(client.BaseURI),
204		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}", pathParameters),
205		autorest.WithQueryParameters(queryParameters))
206	return preparer.Prepare((&http.Request{}).WithContext(ctx))
207}
208
209// DeleteSender sends the Delete request. The method will close the
210// http.Response Body if it receives an error.
211func (client TransactionNodesClient) DeleteSender(req *http.Request) (future TransactionNodesDeleteFuture, err error) {
212	var resp *http.Response
213	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
214	if err != nil {
215		return
216	}
217	var azf azure.Future
218	azf, err = azure.NewFutureFromResponse(resp)
219	future.FutureAPI = &azf
220	future.Result = func(client TransactionNodesClient) (ar autorest.Response, err error) {
221		var done bool
222		done, err = future.DoneWithContext(context.Background(), client)
223		if err != nil {
224			err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesDeleteFuture", "Result", future.Response(), "Polling failure")
225			return
226		}
227		if !done {
228			err = azure.NewAsyncOpIncompleteError("blockchain.TransactionNodesDeleteFuture")
229			return
230		}
231		ar.Response = future.Response()
232		return
233	}
234	return
235}
236
237// DeleteResponder handles the response to the Delete request. The method always
238// closes the http.Response Body.
239func (client TransactionNodesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
240	err = autorest.Respond(
241		resp,
242		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
243		autorest.ByClosing())
244	result.Response = resp
245	return
246}
247
248// Get get the details of the transaction node.
249// Parameters:
250// blockchainMemberName - blockchain member name.
251// transactionNodeName - transaction node name.
252// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
253// from the Azure Resource Manager API or the portal.
254func (client TransactionNodesClient) Get(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (result TransactionNode, err error) {
255	if tracing.IsEnabled() {
256		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.Get")
257		defer func() {
258			sc := -1
259			if result.Response.Response != nil {
260				sc = result.Response.Response.StatusCode
261			}
262			tracing.EndSpan(ctx, sc, err)
263		}()
264	}
265	req, err := client.GetPreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName)
266	if err != nil {
267		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Get", nil, "Failure preparing request")
268		return
269	}
270
271	resp, err := client.GetSender(req)
272	if err != nil {
273		result.Response = autorest.Response{Response: resp}
274		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Get", resp, "Failure sending request")
275		return
276	}
277
278	result, err = client.GetResponder(resp)
279	if err != nil {
280		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Get", resp, "Failure responding to request")
281		return
282	}
283
284	return
285}
286
287// GetPreparer prepares the Get request.
288func (client TransactionNodesClient) GetPreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (*http.Request, error) {
289	pathParameters := map[string]interface{}{
290		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
291		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
292		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
293		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
294	}
295
296	const APIVersion = "2018-06-01-preview"
297	queryParameters := map[string]interface{}{
298		"api-version": APIVersion,
299	}
300
301	preparer := autorest.CreatePreparer(
302		autorest.AsGet(),
303		autorest.WithBaseURL(client.BaseURI),
304		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}", pathParameters),
305		autorest.WithQueryParameters(queryParameters))
306	return preparer.Prepare((&http.Request{}).WithContext(ctx))
307}
308
309// GetSender sends the Get request. The method will close the
310// http.Response Body if it receives an error.
311func (client TransactionNodesClient) GetSender(req *http.Request) (*http.Response, error) {
312	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
313}
314
315// GetResponder handles the response to the Get request. The method always
316// closes the http.Response Body.
317func (client TransactionNodesClient) GetResponder(resp *http.Response) (result TransactionNode, err error) {
318	err = autorest.Respond(
319		resp,
320		azure.WithErrorUnlessStatusCode(http.StatusOK),
321		autorest.ByUnmarshallingJSON(&result),
322		autorest.ByClosing())
323	result.Response = autorest.Response{Response: resp}
324	return
325}
326
327// List lists the transaction nodes for a blockchain member.
328// Parameters:
329// blockchainMemberName - blockchain member name.
330// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
331// from the Azure Resource Manager API or the portal.
332func (client TransactionNodesClient) List(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result TransactionNodeCollectionPage, err error) {
333	if tracing.IsEnabled() {
334		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.List")
335		defer func() {
336			sc := -1
337			if result.tnc.Response.Response != nil {
338				sc = result.tnc.Response.Response.StatusCode
339			}
340			tracing.EndSpan(ctx, sc, err)
341		}()
342	}
343	result.fn = client.listNextResults
344	req, err := client.ListPreparer(ctx, blockchainMemberName, resourceGroupName)
345	if err != nil {
346		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "List", nil, "Failure preparing request")
347		return
348	}
349
350	resp, err := client.ListSender(req)
351	if err != nil {
352		result.tnc.Response = autorest.Response{Response: resp}
353		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "List", resp, "Failure sending request")
354		return
355	}
356
357	result.tnc, err = client.ListResponder(resp)
358	if err != nil {
359		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "List", resp, "Failure responding to request")
360		return
361	}
362	if result.tnc.hasNextLink() && result.tnc.IsEmpty() {
363		err = result.NextWithContext(ctx)
364		return
365	}
366
367	return
368}
369
370// ListPreparer prepares the List request.
371func (client TransactionNodesClient) ListPreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string) (*http.Request, error) {
372	pathParameters := map[string]interface{}{
373		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
374		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
375		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
376	}
377
378	const APIVersion = "2018-06-01-preview"
379	queryParameters := map[string]interface{}{
380		"api-version": APIVersion,
381	}
382
383	preparer := autorest.CreatePreparer(
384		autorest.AsGet(),
385		autorest.WithBaseURL(client.BaseURI),
386		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes", pathParameters),
387		autorest.WithQueryParameters(queryParameters))
388	return preparer.Prepare((&http.Request{}).WithContext(ctx))
389}
390
391// ListSender sends the List request. The method will close the
392// http.Response Body if it receives an error.
393func (client TransactionNodesClient) ListSender(req *http.Request) (*http.Response, error) {
394	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
395}
396
397// ListResponder handles the response to the List request. The method always
398// closes the http.Response Body.
399func (client TransactionNodesClient) ListResponder(resp *http.Response) (result TransactionNodeCollection, err error) {
400	err = autorest.Respond(
401		resp,
402		azure.WithErrorUnlessStatusCode(http.StatusOK),
403		autorest.ByUnmarshallingJSON(&result),
404		autorest.ByClosing())
405	result.Response = autorest.Response{Response: resp}
406	return
407}
408
409// listNextResults retrieves the next set of results, if any.
410func (client TransactionNodesClient) listNextResults(ctx context.Context, lastResults TransactionNodeCollection) (result TransactionNodeCollection, err error) {
411	req, err := lastResults.transactionNodeCollectionPreparer(ctx)
412	if err != nil {
413		return result, autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "listNextResults", nil, "Failure preparing next results request")
414	}
415	if req == nil {
416		return
417	}
418	resp, err := client.ListSender(req)
419	if err != nil {
420		result.Response = autorest.Response{Response: resp}
421		return result, autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "listNextResults", resp, "Failure sending next results request")
422	}
423	result, err = client.ListResponder(resp)
424	if err != nil {
425		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "listNextResults", resp, "Failure responding to next results request")
426	}
427	return
428}
429
430// ListComplete enumerates all values, automatically crossing page boundaries as required.
431func (client TransactionNodesClient) ListComplete(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result TransactionNodeCollectionIterator, err error) {
432	if tracing.IsEnabled() {
433		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.List")
434		defer func() {
435			sc := -1
436			if result.Response().Response.Response != nil {
437				sc = result.page.Response().Response.Response.StatusCode
438			}
439			tracing.EndSpan(ctx, sc, err)
440		}()
441	}
442	result.page, err = client.List(ctx, blockchainMemberName, resourceGroupName)
443	return
444}
445
446// ListAPIKeys list the API keys for the transaction node.
447// Parameters:
448// blockchainMemberName - blockchain member name.
449// transactionNodeName - transaction node name.
450// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
451// from the Azure Resource Manager API or the portal.
452func (client TransactionNodesClient) ListAPIKeys(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (result APIKeyCollection, err error) {
453	if tracing.IsEnabled() {
454		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.ListAPIKeys")
455		defer func() {
456			sc := -1
457			if result.Response.Response != nil {
458				sc = result.Response.Response.StatusCode
459			}
460			tracing.EndSpan(ctx, sc, err)
461		}()
462	}
463	req, err := client.ListAPIKeysPreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName)
464	if err != nil {
465		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListAPIKeys", nil, "Failure preparing request")
466		return
467	}
468
469	resp, err := client.ListAPIKeysSender(req)
470	if err != nil {
471		result.Response = autorest.Response{Response: resp}
472		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListAPIKeys", resp, "Failure sending request")
473		return
474	}
475
476	result, err = client.ListAPIKeysResponder(resp)
477	if err != nil {
478		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListAPIKeys", resp, "Failure responding to request")
479		return
480	}
481
482	return
483}
484
485// ListAPIKeysPreparer prepares the ListAPIKeys request.
486func (client TransactionNodesClient) ListAPIKeysPreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string) (*http.Request, error) {
487	pathParameters := map[string]interface{}{
488		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
489		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
490		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
491		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
492	}
493
494	const APIVersion = "2018-06-01-preview"
495	queryParameters := map[string]interface{}{
496		"api-version": APIVersion,
497	}
498
499	preparer := autorest.CreatePreparer(
500		autorest.AsPost(),
501		autorest.WithBaseURL(client.BaseURI),
502		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/listApiKeys", pathParameters),
503		autorest.WithQueryParameters(queryParameters))
504	return preparer.Prepare((&http.Request{}).WithContext(ctx))
505}
506
507// ListAPIKeysSender sends the ListAPIKeys request. The method will close the
508// http.Response Body if it receives an error.
509func (client TransactionNodesClient) ListAPIKeysSender(req *http.Request) (*http.Response, error) {
510	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
511}
512
513// ListAPIKeysResponder handles the response to the ListAPIKeys request. The method always
514// closes the http.Response Body.
515func (client TransactionNodesClient) ListAPIKeysResponder(resp *http.Response) (result APIKeyCollection, err error) {
516	err = autorest.Respond(
517		resp,
518		azure.WithErrorUnlessStatusCode(http.StatusOK),
519		autorest.ByUnmarshallingJSON(&result),
520		autorest.ByClosing())
521	result.Response = autorest.Response{Response: resp}
522	return
523}
524
525// ListRegenerateAPIKeys regenerate the API keys for the blockchain member.
526// Parameters:
527// blockchainMemberName - blockchain member name.
528// transactionNodeName - transaction node name.
529// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
530// from the Azure Resource Manager API or the portal.
531// APIKey - api key to be regenerated
532func (client TransactionNodesClient) ListRegenerateAPIKeys(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, APIKey *APIKey) (result APIKeyCollection, err error) {
533	if tracing.IsEnabled() {
534		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.ListRegenerateAPIKeys")
535		defer func() {
536			sc := -1
537			if result.Response.Response != nil {
538				sc = result.Response.Response.StatusCode
539			}
540			tracing.EndSpan(ctx, sc, err)
541		}()
542	}
543	req, err := client.ListRegenerateAPIKeysPreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, APIKey)
544	if err != nil {
545		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListRegenerateAPIKeys", nil, "Failure preparing request")
546		return
547	}
548
549	resp, err := client.ListRegenerateAPIKeysSender(req)
550	if err != nil {
551		result.Response = autorest.Response{Response: resp}
552		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListRegenerateAPIKeys", resp, "Failure sending request")
553		return
554	}
555
556	result, err = client.ListRegenerateAPIKeysResponder(resp)
557	if err != nil {
558		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "ListRegenerateAPIKeys", resp, "Failure responding to request")
559		return
560	}
561
562	return
563}
564
565// ListRegenerateAPIKeysPreparer prepares the ListRegenerateAPIKeys request.
566func (client TransactionNodesClient) ListRegenerateAPIKeysPreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, APIKey *APIKey) (*http.Request, error) {
567	pathParameters := map[string]interface{}{
568		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
569		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
570		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
571		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
572	}
573
574	const APIVersion = "2018-06-01-preview"
575	queryParameters := map[string]interface{}{
576		"api-version": APIVersion,
577	}
578
579	preparer := autorest.CreatePreparer(
580		autorest.AsContentType("application/json; charset=utf-8"),
581		autorest.AsPost(),
582		autorest.WithBaseURL(client.BaseURI),
583		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/regenerateApiKeys", pathParameters),
584		autorest.WithQueryParameters(queryParameters))
585	if APIKey != nil {
586		preparer = autorest.DecoratePreparer(preparer,
587			autorest.WithJSON(APIKey))
588	}
589	return preparer.Prepare((&http.Request{}).WithContext(ctx))
590}
591
592// ListRegenerateAPIKeysSender sends the ListRegenerateAPIKeys request. The method will close the
593// http.Response Body if it receives an error.
594func (client TransactionNodesClient) ListRegenerateAPIKeysSender(req *http.Request) (*http.Response, error) {
595	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
596}
597
598// ListRegenerateAPIKeysResponder handles the response to the ListRegenerateAPIKeys request. The method always
599// closes the http.Response Body.
600func (client TransactionNodesClient) ListRegenerateAPIKeysResponder(resp *http.Response) (result APIKeyCollection, err error) {
601	err = autorest.Respond(
602		resp,
603		azure.WithErrorUnlessStatusCode(http.StatusOK),
604		autorest.ByUnmarshallingJSON(&result),
605		autorest.ByClosing())
606	result.Response = autorest.Response{Response: resp}
607	return
608}
609
610// Update update the transaction node.
611// Parameters:
612// blockchainMemberName - blockchain member name.
613// transactionNodeName - transaction node name.
614// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value
615// from the Azure Resource Manager API or the portal.
616// transactionNode - payload to create the transaction node.
617func (client TransactionNodesClient) Update(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, transactionNode *TransactionNodeUpdate) (result TransactionNode, err error) {
618	if tracing.IsEnabled() {
619		ctx = tracing.StartSpan(ctx, fqdn+"/TransactionNodesClient.Update")
620		defer func() {
621			sc := -1
622			if result.Response.Response != nil {
623				sc = result.Response.Response.StatusCode
624			}
625			tracing.EndSpan(ctx, sc, err)
626		}()
627	}
628	req, err := client.UpdatePreparer(ctx, blockchainMemberName, transactionNodeName, resourceGroupName, transactionNode)
629	if err != nil {
630		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Update", nil, "Failure preparing request")
631		return
632	}
633
634	resp, err := client.UpdateSender(req)
635	if err != nil {
636		result.Response = autorest.Response{Response: resp}
637		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Update", resp, "Failure sending request")
638		return
639	}
640
641	result, err = client.UpdateResponder(resp)
642	if err != nil {
643		err = autorest.NewErrorWithError(err, "blockchain.TransactionNodesClient", "Update", resp, "Failure responding to request")
644		return
645	}
646
647	return
648}
649
650// UpdatePreparer prepares the Update request.
651func (client TransactionNodesClient) UpdatePreparer(ctx context.Context, blockchainMemberName string, transactionNodeName string, resourceGroupName string, transactionNode *TransactionNodeUpdate) (*http.Request, error) {
652	pathParameters := map[string]interface{}{
653		"blockchainMemberName": autorest.Encode("path", blockchainMemberName),
654		"resourceGroupName":    autorest.Encode("path", resourceGroupName),
655		"subscriptionId":       autorest.Encode("path", client.SubscriptionID),
656		"transactionNodeName":  autorest.Encode("path", transactionNodeName),
657	}
658
659	const APIVersion = "2018-06-01-preview"
660	queryParameters := map[string]interface{}{
661		"api-version": APIVersion,
662	}
663
664	preparer := autorest.CreatePreparer(
665		autorest.AsContentType("application/json; charset=utf-8"),
666		autorest.AsPatch(),
667		autorest.WithBaseURL(client.BaseURI),
668		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}", pathParameters),
669		autorest.WithQueryParameters(queryParameters))
670	if transactionNode != nil {
671		preparer = autorest.DecoratePreparer(preparer,
672			autorest.WithJSON(transactionNode))
673	}
674	return preparer.Prepare((&http.Request{}).WithContext(ctx))
675}
676
677// UpdateSender sends the Update request. The method will close the
678// http.Response Body if it receives an error.
679func (client TransactionNodesClient) UpdateSender(req *http.Request) (*http.Response, error) {
680	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
681}
682
683// UpdateResponder handles the response to the Update request. The method always
684// closes the http.Response Body.
685func (client TransactionNodesClient) UpdateResponder(resp *http.Response) (result TransactionNode, err error) {
686	err = autorest.Respond(
687		resp,
688		azure.WithErrorUnlessStatusCode(http.StatusOK),
689		autorest.ByUnmarshallingJSON(&result),
690		autorest.ByClosing())
691	result.Response = autorest.Response{Response: resp}
692	return
693}
694