...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/blockchain/mgmt/2018-06-01-preview/blockchain/transactionnodes.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/blockchain/mgmt/2018-06-01-preview/blockchain

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

View as plain text