1package 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 9import ( 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// MembersClient is the REST API for Azure Blockchain Service 18type MembersClient struct { 19 BaseClient 20} 21 22// NewMembersClient creates an instance of the MembersClient client. 23func NewMembersClient(subscriptionID string) MembersClient { 24 return NewMembersClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewMembersClientWithBaseURI creates an instance of the MembersClient client using a custom endpoint. Use this when 28// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewMembersClientWithBaseURI(baseURI string, subscriptionID string) MembersClient { 30 return MembersClient{NewWithBaseURI(baseURI, subscriptionID)} 31} 32 33// Create create a blockchain member. 34// Parameters: 35// blockchainMemberName - blockchain member name. 36// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 37// from the Azure Resource Manager API or the portal. 38// blockchainMember - payload to create a blockchain member. 39func (client MembersClient) Create(ctx context.Context, blockchainMemberName string, resourceGroupName string, blockchainMember *Member) (result MembersCreateFuture, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.Create") 42 defer func() { 43 sc := -1 44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 45 sc = result.FutureAPI.Response().StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 req, err := client.CreatePreparer(ctx, blockchainMemberName, resourceGroupName, blockchainMember) 51 if err != nil { 52 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Create", nil, "Failure preparing request") 53 return 54 } 55 56 result, err = client.CreateSender(req) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Create", nil, "Failure sending request") 59 return 60 } 61 62 return 63} 64 65// CreatePreparer prepares the Create request. 66func (client MembersClient) CreatePreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string, blockchainMember *Member) (*http.Request, error) { 67 pathParameters := map[string]interface{}{ 68 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 69 "resourceGroupName": autorest.Encode("path", resourceGroupName), 70 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 71 } 72 73 const APIVersion = "2018-06-01-preview" 74 queryParameters := map[string]interface{}{ 75 "api-version": APIVersion, 76 } 77 78 preparer := autorest.CreatePreparer( 79 autorest.AsContentType("application/json; charset=utf-8"), 80 autorest.AsPut(), 81 autorest.WithBaseURL(client.BaseURI), 82 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}", pathParameters), 83 autorest.WithQueryParameters(queryParameters)) 84 if blockchainMember != nil { 85 preparer = autorest.DecoratePreparer(preparer, 86 autorest.WithJSON(blockchainMember)) 87 } 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// CreateSender sends the Create request. The method will close the 92// http.Response Body if it receives an error. 93func (client MembersClient) CreateSender(req *http.Request) (future MembersCreateFuture, err error) { 94 var resp *http.Response 95 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 96 if err != nil { 97 return 98 } 99 var azf azure.Future 100 azf, err = azure.NewFutureFromResponse(resp) 101 future.FutureAPI = &azf 102 future.Result = future.result 103 return 104} 105 106// CreateResponder handles the response to the Create request. The method always 107// closes the http.Response Body. 108func (client MembersClient) CreateResponder(resp *http.Response) (result Member, err error) { 109 err = autorest.Respond( 110 resp, 111 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 112 autorest.ByUnmarshallingJSON(&result), 113 autorest.ByClosing()) 114 result.Response = autorest.Response{Response: resp} 115 return 116} 117 118// Delete delete a blockchain member. 119// Parameters: 120// blockchainMemberName - blockchain member name 121// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 122// from the Azure Resource Manager API or the portal. 123func (client MembersClient) Delete(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result MembersDeleteFuture, err error) { 124 if tracing.IsEnabled() { 125 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.Delete") 126 defer func() { 127 sc := -1 128 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 129 sc = result.FutureAPI.Response().StatusCode 130 } 131 tracing.EndSpan(ctx, sc, err) 132 }() 133 } 134 req, err := client.DeletePreparer(ctx, blockchainMemberName, resourceGroupName) 135 if err != nil { 136 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Delete", nil, "Failure preparing request") 137 return 138 } 139 140 result, err = client.DeleteSender(req) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Delete", nil, "Failure sending request") 143 return 144 } 145 146 return 147} 148 149// DeletePreparer prepares the Delete request. 150func (client MembersClient) DeletePreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string) (*http.Request, error) { 151 pathParameters := map[string]interface{}{ 152 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 153 "resourceGroupName": autorest.Encode("path", resourceGroupName), 154 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 155 } 156 157 const APIVersion = "2018-06-01-preview" 158 queryParameters := map[string]interface{}{ 159 "api-version": APIVersion, 160 } 161 162 preparer := autorest.CreatePreparer( 163 autorest.AsDelete(), 164 autorest.WithBaseURL(client.BaseURI), 165 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}", pathParameters), 166 autorest.WithQueryParameters(queryParameters)) 167 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 168} 169 170// DeleteSender sends the Delete request. The method will close the 171// http.Response Body if it receives an error. 172func (client MembersClient) DeleteSender(req *http.Request) (future MembersDeleteFuture, err error) { 173 var resp *http.Response 174 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 175 if err != nil { 176 return 177 } 178 var azf azure.Future 179 azf, err = azure.NewFutureFromResponse(resp) 180 future.FutureAPI = &azf 181 future.Result = future.result 182 return 183} 184 185// DeleteResponder handles the response to the Delete request. The method always 186// closes the http.Response Body. 187func (client MembersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 188 err = autorest.Respond( 189 resp, 190 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 191 autorest.ByClosing()) 192 result.Response = resp 193 return 194} 195 196// Get get details about a blockchain member. 197// Parameters: 198// blockchainMemberName - blockchain member name. 199// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 200// from the Azure Resource Manager API or the portal. 201func (client MembersClient) Get(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result Member, err error) { 202 if tracing.IsEnabled() { 203 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.Get") 204 defer func() { 205 sc := -1 206 if result.Response.Response != nil { 207 sc = result.Response.Response.StatusCode 208 } 209 tracing.EndSpan(ctx, sc, err) 210 }() 211 } 212 req, err := client.GetPreparer(ctx, blockchainMemberName, resourceGroupName) 213 if err != nil { 214 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Get", nil, "Failure preparing request") 215 return 216 } 217 218 resp, err := client.GetSender(req) 219 if err != nil { 220 result.Response = autorest.Response{Response: resp} 221 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Get", resp, "Failure sending request") 222 return 223 } 224 225 result, err = client.GetResponder(resp) 226 if err != nil { 227 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Get", resp, "Failure responding to request") 228 return 229 } 230 231 return 232} 233 234// GetPreparer prepares the Get request. 235func (client MembersClient) GetPreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string) (*http.Request, error) { 236 pathParameters := map[string]interface{}{ 237 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 238 "resourceGroupName": autorest.Encode("path", resourceGroupName), 239 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 240 } 241 242 const APIVersion = "2018-06-01-preview" 243 queryParameters := map[string]interface{}{ 244 "api-version": APIVersion, 245 } 246 247 preparer := autorest.CreatePreparer( 248 autorest.AsGet(), 249 autorest.WithBaseURL(client.BaseURI), 250 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}", pathParameters), 251 autorest.WithQueryParameters(queryParameters)) 252 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 253} 254 255// GetSender sends the Get request. The method will close the 256// http.Response Body if it receives an error. 257func (client MembersClient) GetSender(req *http.Request) (*http.Response, error) { 258 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 259} 260 261// GetResponder handles the response to the Get request. The method always 262// closes the http.Response Body. 263func (client MembersClient) GetResponder(resp *http.Response) (result Member, err error) { 264 err = autorest.Respond( 265 resp, 266 azure.WithErrorUnlessStatusCode(http.StatusOK), 267 autorest.ByUnmarshallingJSON(&result), 268 autorest.ByClosing()) 269 result.Response = autorest.Response{Response: resp} 270 return 271} 272 273// List lists the blockchain members for a resource group. 274// Parameters: 275// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 276// from the Azure Resource Manager API or the portal. 277func (client MembersClient) List(ctx context.Context, resourceGroupName string) (result MemberCollectionPage, err error) { 278 if tracing.IsEnabled() { 279 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.List") 280 defer func() { 281 sc := -1 282 if result.mc.Response.Response != nil { 283 sc = result.mc.Response.Response.StatusCode 284 } 285 tracing.EndSpan(ctx, sc, err) 286 }() 287 } 288 result.fn = client.listNextResults 289 req, err := client.ListPreparer(ctx, resourceGroupName) 290 if err != nil { 291 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "List", nil, "Failure preparing request") 292 return 293 } 294 295 resp, err := client.ListSender(req) 296 if err != nil { 297 result.mc.Response = autorest.Response{Response: resp} 298 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "List", resp, "Failure sending request") 299 return 300 } 301 302 result.mc, err = client.ListResponder(resp) 303 if err != nil { 304 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "List", resp, "Failure responding to request") 305 return 306 } 307 if result.mc.hasNextLink() && result.mc.IsEmpty() { 308 err = result.NextWithContext(ctx) 309 return 310 } 311 312 return 313} 314 315// ListPreparer prepares the List request. 316func (client MembersClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 317 pathParameters := map[string]interface{}{ 318 "resourceGroupName": autorest.Encode("path", resourceGroupName), 319 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 320 } 321 322 const APIVersion = "2018-06-01-preview" 323 queryParameters := map[string]interface{}{ 324 "api-version": APIVersion, 325 } 326 327 preparer := autorest.CreatePreparer( 328 autorest.AsGet(), 329 autorest.WithBaseURL(client.BaseURI), 330 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers", pathParameters), 331 autorest.WithQueryParameters(queryParameters)) 332 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 333} 334 335// ListSender sends the List request. The method will close the 336// http.Response Body if it receives an error. 337func (client MembersClient) ListSender(req *http.Request) (*http.Response, error) { 338 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 339} 340 341// ListResponder handles the response to the List request. The method always 342// closes the http.Response Body. 343func (client MembersClient) ListResponder(resp *http.Response) (result MemberCollection, err error) { 344 err = autorest.Respond( 345 resp, 346 azure.WithErrorUnlessStatusCode(http.StatusOK), 347 autorest.ByUnmarshallingJSON(&result), 348 autorest.ByClosing()) 349 result.Response = autorest.Response{Response: resp} 350 return 351} 352 353// listNextResults retrieves the next set of results, if any. 354func (client MembersClient) listNextResults(ctx context.Context, lastResults MemberCollection) (result MemberCollection, err error) { 355 req, err := lastResults.memberCollectionPreparer(ctx) 356 if err != nil { 357 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listNextResults", nil, "Failure preparing next results request") 358 } 359 if req == nil { 360 return 361 } 362 resp, err := client.ListSender(req) 363 if err != nil { 364 result.Response = autorest.Response{Response: resp} 365 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listNextResults", resp, "Failure sending next results request") 366 } 367 result, err = client.ListResponder(resp) 368 if err != nil { 369 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "listNextResults", resp, "Failure responding to next results request") 370 } 371 return 372} 373 374// ListComplete enumerates all values, automatically crossing page boundaries as required. 375func (client MembersClient) ListComplete(ctx context.Context, resourceGroupName string) (result MemberCollectionIterator, err error) { 376 if tracing.IsEnabled() { 377 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.List") 378 defer func() { 379 sc := -1 380 if result.Response().Response.Response != nil { 381 sc = result.page.Response().Response.Response.StatusCode 382 } 383 tracing.EndSpan(ctx, sc, err) 384 }() 385 } 386 result.page, err = client.List(ctx, resourceGroupName) 387 return 388} 389 390// ListAll lists the blockchain members for a subscription. 391func (client MembersClient) ListAll(ctx context.Context) (result MemberCollectionPage, err error) { 392 if tracing.IsEnabled() { 393 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListAll") 394 defer func() { 395 sc := -1 396 if result.mc.Response.Response != nil { 397 sc = result.mc.Response.Response.StatusCode 398 } 399 tracing.EndSpan(ctx, sc, err) 400 }() 401 } 402 result.fn = client.listAllNextResults 403 req, err := client.ListAllPreparer(ctx) 404 if err != nil { 405 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAll", nil, "Failure preparing request") 406 return 407 } 408 409 resp, err := client.ListAllSender(req) 410 if err != nil { 411 result.mc.Response = autorest.Response{Response: resp} 412 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAll", resp, "Failure sending request") 413 return 414 } 415 416 result.mc, err = client.ListAllResponder(resp) 417 if err != nil { 418 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAll", resp, "Failure responding to request") 419 return 420 } 421 if result.mc.hasNextLink() && result.mc.IsEmpty() { 422 err = result.NextWithContext(ctx) 423 return 424 } 425 426 return 427} 428 429// ListAllPreparer prepares the ListAll request. 430func (client MembersClient) ListAllPreparer(ctx context.Context) (*http.Request, error) { 431 pathParameters := map[string]interface{}{ 432 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 433 } 434 435 const APIVersion = "2018-06-01-preview" 436 queryParameters := map[string]interface{}{ 437 "api-version": APIVersion, 438 } 439 440 preparer := autorest.CreatePreparer( 441 autorest.AsGet(), 442 autorest.WithBaseURL(client.BaseURI), 443 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/blockchainMembers", pathParameters), 444 autorest.WithQueryParameters(queryParameters)) 445 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 446} 447 448// ListAllSender sends the ListAll request. The method will close the 449// http.Response Body if it receives an error. 450func (client MembersClient) ListAllSender(req *http.Request) (*http.Response, error) { 451 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 452} 453 454// ListAllResponder handles the response to the ListAll request. The method always 455// closes the http.Response Body. 456func (client MembersClient) ListAllResponder(resp *http.Response) (result MemberCollection, err error) { 457 err = autorest.Respond( 458 resp, 459 azure.WithErrorUnlessStatusCode(http.StatusOK), 460 autorest.ByUnmarshallingJSON(&result), 461 autorest.ByClosing()) 462 result.Response = autorest.Response{Response: resp} 463 return 464} 465 466// listAllNextResults retrieves the next set of results, if any. 467func (client MembersClient) listAllNextResults(ctx context.Context, lastResults MemberCollection) (result MemberCollection, err error) { 468 req, err := lastResults.memberCollectionPreparer(ctx) 469 if err != nil { 470 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listAllNextResults", nil, "Failure preparing next results request") 471 } 472 if req == nil { 473 return 474 } 475 resp, err := client.ListAllSender(req) 476 if err != nil { 477 result.Response = autorest.Response{Response: resp} 478 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listAllNextResults", resp, "Failure sending next results request") 479 } 480 result, err = client.ListAllResponder(resp) 481 if err != nil { 482 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "listAllNextResults", resp, "Failure responding to next results request") 483 } 484 return 485} 486 487// ListAllComplete enumerates all values, automatically crossing page boundaries as required. 488func (client MembersClient) ListAllComplete(ctx context.Context) (result MemberCollectionIterator, err error) { 489 if tracing.IsEnabled() { 490 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListAll") 491 defer func() { 492 sc := -1 493 if result.Response().Response.Response != nil { 494 sc = result.page.Response().Response.Response.StatusCode 495 } 496 tracing.EndSpan(ctx, sc, err) 497 }() 498 } 499 result.page, err = client.ListAll(ctx) 500 return 501} 502 503// ListAPIKeys lists the API keys for a blockchain member. 504// Parameters: 505// blockchainMemberName - blockchain member name. 506// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 507// from the Azure Resource Manager API or the portal. 508func (client MembersClient) ListAPIKeys(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result APIKeyCollection, err error) { 509 if tracing.IsEnabled() { 510 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListAPIKeys") 511 defer func() { 512 sc := -1 513 if result.Response.Response != nil { 514 sc = result.Response.Response.StatusCode 515 } 516 tracing.EndSpan(ctx, sc, err) 517 }() 518 } 519 req, err := client.ListAPIKeysPreparer(ctx, blockchainMemberName, resourceGroupName) 520 if err != nil { 521 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAPIKeys", nil, "Failure preparing request") 522 return 523 } 524 525 resp, err := client.ListAPIKeysSender(req) 526 if err != nil { 527 result.Response = autorest.Response{Response: resp} 528 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAPIKeys", resp, "Failure sending request") 529 return 530 } 531 532 result, err = client.ListAPIKeysResponder(resp) 533 if err != nil { 534 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListAPIKeys", resp, "Failure responding to request") 535 return 536 } 537 538 return 539} 540 541// ListAPIKeysPreparer prepares the ListAPIKeys request. 542func (client MembersClient) ListAPIKeysPreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string) (*http.Request, error) { 543 pathParameters := map[string]interface{}{ 544 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 545 "resourceGroupName": autorest.Encode("path", resourceGroupName), 546 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 547 } 548 549 const APIVersion = "2018-06-01-preview" 550 queryParameters := map[string]interface{}{ 551 "api-version": APIVersion, 552 } 553 554 preparer := autorest.CreatePreparer( 555 autorest.AsPost(), 556 autorest.WithBaseURL(client.BaseURI), 557 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/listApiKeys", pathParameters), 558 autorest.WithQueryParameters(queryParameters)) 559 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 560} 561 562// ListAPIKeysSender sends the ListAPIKeys request. The method will close the 563// http.Response Body if it receives an error. 564func (client MembersClient) ListAPIKeysSender(req *http.Request) (*http.Response, error) { 565 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 566} 567 568// ListAPIKeysResponder handles the response to the ListAPIKeys request. The method always 569// closes the http.Response Body. 570func (client MembersClient) ListAPIKeysResponder(resp *http.Response) (result APIKeyCollection, err error) { 571 err = autorest.Respond( 572 resp, 573 azure.WithErrorUnlessStatusCode(http.StatusOK), 574 autorest.ByUnmarshallingJSON(&result), 575 autorest.ByClosing()) 576 result.Response = autorest.Response{Response: resp} 577 return 578} 579 580// ListConsortiumMembers lists the consortium members for a blockchain member. 581// Parameters: 582// blockchainMemberName - blockchain member name. 583// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 584// from the Azure Resource Manager API or the portal. 585func (client MembersClient) ListConsortiumMembers(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result ConsortiumMemberCollectionPage, err error) { 586 if tracing.IsEnabled() { 587 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListConsortiumMembers") 588 defer func() { 589 sc := -1 590 if result.cmc.Response.Response != nil { 591 sc = result.cmc.Response.Response.StatusCode 592 } 593 tracing.EndSpan(ctx, sc, err) 594 }() 595 } 596 result.fn = client.listConsortiumMembersNextResults 597 req, err := client.ListConsortiumMembersPreparer(ctx, blockchainMemberName, resourceGroupName) 598 if err != nil { 599 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListConsortiumMembers", nil, "Failure preparing request") 600 return 601 } 602 603 resp, err := client.ListConsortiumMembersSender(req) 604 if err != nil { 605 result.cmc.Response = autorest.Response{Response: resp} 606 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListConsortiumMembers", resp, "Failure sending request") 607 return 608 } 609 610 result.cmc, err = client.ListConsortiumMembersResponder(resp) 611 if err != nil { 612 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListConsortiumMembers", resp, "Failure responding to request") 613 return 614 } 615 if result.cmc.hasNextLink() && result.cmc.IsEmpty() { 616 err = result.NextWithContext(ctx) 617 return 618 } 619 620 return 621} 622 623// ListConsortiumMembersPreparer prepares the ListConsortiumMembers request. 624func (client MembersClient) ListConsortiumMembersPreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string) (*http.Request, error) { 625 pathParameters := map[string]interface{}{ 626 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 627 "resourceGroupName": autorest.Encode("path", resourceGroupName), 628 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 629 } 630 631 const APIVersion = "2018-06-01-preview" 632 queryParameters := map[string]interface{}{ 633 "api-version": APIVersion, 634 } 635 636 preparer := autorest.CreatePreparer( 637 autorest.AsGet(), 638 autorest.WithBaseURL(client.BaseURI), 639 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/consortiumMembers", pathParameters), 640 autorest.WithQueryParameters(queryParameters)) 641 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 642} 643 644// ListConsortiumMembersSender sends the ListConsortiumMembers request. The method will close the 645// http.Response Body if it receives an error. 646func (client MembersClient) ListConsortiumMembersSender(req *http.Request) (*http.Response, error) { 647 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 648} 649 650// ListConsortiumMembersResponder handles the response to the ListConsortiumMembers request. The method always 651// closes the http.Response Body. 652func (client MembersClient) ListConsortiumMembersResponder(resp *http.Response) (result ConsortiumMemberCollection, err error) { 653 err = autorest.Respond( 654 resp, 655 azure.WithErrorUnlessStatusCode(http.StatusOK), 656 autorest.ByUnmarshallingJSON(&result), 657 autorest.ByClosing()) 658 result.Response = autorest.Response{Response: resp} 659 return 660} 661 662// listConsortiumMembersNextResults retrieves the next set of results, if any. 663func (client MembersClient) listConsortiumMembersNextResults(ctx context.Context, lastResults ConsortiumMemberCollection) (result ConsortiumMemberCollection, err error) { 664 req, err := lastResults.consortiumMemberCollectionPreparer(ctx) 665 if err != nil { 666 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listConsortiumMembersNextResults", nil, "Failure preparing next results request") 667 } 668 if req == nil { 669 return 670 } 671 resp, err := client.ListConsortiumMembersSender(req) 672 if err != nil { 673 result.Response = autorest.Response{Response: resp} 674 return result, autorest.NewErrorWithError(err, "blockchain.MembersClient", "listConsortiumMembersNextResults", resp, "Failure sending next results request") 675 } 676 result, err = client.ListConsortiumMembersResponder(resp) 677 if err != nil { 678 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "listConsortiumMembersNextResults", resp, "Failure responding to next results request") 679 } 680 return 681} 682 683// ListConsortiumMembersComplete enumerates all values, automatically crossing page boundaries as required. 684func (client MembersClient) ListConsortiumMembersComplete(ctx context.Context, blockchainMemberName string, resourceGroupName string) (result ConsortiumMemberCollectionIterator, err error) { 685 if tracing.IsEnabled() { 686 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListConsortiumMembers") 687 defer func() { 688 sc := -1 689 if result.Response().Response.Response != nil { 690 sc = result.page.Response().Response.Response.StatusCode 691 } 692 tracing.EndSpan(ctx, sc, err) 693 }() 694 } 695 result.page, err = client.ListConsortiumMembers(ctx, blockchainMemberName, resourceGroupName) 696 return 697} 698 699// ListRegenerateAPIKeys regenerate the API keys for a blockchain member. 700// Parameters: 701// blockchainMemberName - blockchain member name. 702// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 703// from the Azure Resource Manager API or the portal. 704// APIKey - api key to be regenerate 705func (client MembersClient) ListRegenerateAPIKeys(ctx context.Context, blockchainMemberName string, resourceGroupName string, APIKey *APIKey) (result APIKeyCollection, err error) { 706 if tracing.IsEnabled() { 707 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.ListRegenerateAPIKeys") 708 defer func() { 709 sc := -1 710 if result.Response.Response != nil { 711 sc = result.Response.Response.StatusCode 712 } 713 tracing.EndSpan(ctx, sc, err) 714 }() 715 } 716 req, err := client.ListRegenerateAPIKeysPreparer(ctx, blockchainMemberName, resourceGroupName, APIKey) 717 if err != nil { 718 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListRegenerateAPIKeys", nil, "Failure preparing request") 719 return 720 } 721 722 resp, err := client.ListRegenerateAPIKeysSender(req) 723 if err != nil { 724 result.Response = autorest.Response{Response: resp} 725 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListRegenerateAPIKeys", resp, "Failure sending request") 726 return 727 } 728 729 result, err = client.ListRegenerateAPIKeysResponder(resp) 730 if err != nil { 731 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "ListRegenerateAPIKeys", resp, "Failure responding to request") 732 return 733 } 734 735 return 736} 737 738// ListRegenerateAPIKeysPreparer prepares the ListRegenerateAPIKeys request. 739func (client MembersClient) ListRegenerateAPIKeysPreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string, APIKey *APIKey) (*http.Request, error) { 740 pathParameters := map[string]interface{}{ 741 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 742 "resourceGroupName": autorest.Encode("path", resourceGroupName), 743 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 744 } 745 746 const APIVersion = "2018-06-01-preview" 747 queryParameters := map[string]interface{}{ 748 "api-version": APIVersion, 749 } 750 751 preparer := autorest.CreatePreparer( 752 autorest.AsContentType("application/json; charset=utf-8"), 753 autorest.AsPost(), 754 autorest.WithBaseURL(client.BaseURI), 755 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/regenerateApiKeys", pathParameters), 756 autorest.WithQueryParameters(queryParameters)) 757 if APIKey != nil { 758 preparer = autorest.DecoratePreparer(preparer, 759 autorest.WithJSON(APIKey)) 760 } 761 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 762} 763 764// ListRegenerateAPIKeysSender sends the ListRegenerateAPIKeys request. The method will close the 765// http.Response Body if it receives an error. 766func (client MembersClient) ListRegenerateAPIKeysSender(req *http.Request) (*http.Response, error) { 767 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 768} 769 770// ListRegenerateAPIKeysResponder handles the response to the ListRegenerateAPIKeys request. The method always 771// closes the http.Response Body. 772func (client MembersClient) ListRegenerateAPIKeysResponder(resp *http.Response) (result APIKeyCollection, err error) { 773 err = autorest.Respond( 774 resp, 775 azure.WithErrorUnlessStatusCode(http.StatusOK), 776 autorest.ByUnmarshallingJSON(&result), 777 autorest.ByClosing()) 778 result.Response = autorest.Response{Response: resp} 779 return 780} 781 782// Update update a blockchain member. 783// Parameters: 784// blockchainMemberName - blockchain member name. 785// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 786// from the Azure Resource Manager API or the portal. 787// blockchainMember - payload to update the blockchain member. 788func (client MembersClient) Update(ctx context.Context, blockchainMemberName string, resourceGroupName string, blockchainMember *MemberUpdate) (result Member, err error) { 789 if tracing.IsEnabled() { 790 ctx = tracing.StartSpan(ctx, fqdn+"/MembersClient.Update") 791 defer func() { 792 sc := -1 793 if result.Response.Response != nil { 794 sc = result.Response.Response.StatusCode 795 } 796 tracing.EndSpan(ctx, sc, err) 797 }() 798 } 799 req, err := client.UpdatePreparer(ctx, blockchainMemberName, resourceGroupName, blockchainMember) 800 if err != nil { 801 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Update", nil, "Failure preparing request") 802 return 803 } 804 805 resp, err := client.UpdateSender(req) 806 if err != nil { 807 result.Response = autorest.Response{Response: resp} 808 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Update", resp, "Failure sending request") 809 return 810 } 811 812 result, err = client.UpdateResponder(resp) 813 if err != nil { 814 err = autorest.NewErrorWithError(err, "blockchain.MembersClient", "Update", resp, "Failure responding to request") 815 return 816 } 817 818 return 819} 820 821// UpdatePreparer prepares the Update request. 822func (client MembersClient) UpdatePreparer(ctx context.Context, blockchainMemberName string, resourceGroupName string, blockchainMember *MemberUpdate) (*http.Request, error) { 823 pathParameters := map[string]interface{}{ 824 "blockchainMemberName": autorest.Encode("path", blockchainMemberName), 825 "resourceGroupName": autorest.Encode("path", resourceGroupName), 826 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 827 } 828 829 const APIVersion = "2018-06-01-preview" 830 queryParameters := map[string]interface{}{ 831 "api-version": APIVersion, 832 } 833 834 preparer := autorest.CreatePreparer( 835 autorest.AsContentType("application/json; charset=utf-8"), 836 autorest.AsPatch(), 837 autorest.WithBaseURL(client.BaseURI), 838 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}", pathParameters), 839 autorest.WithQueryParameters(queryParameters)) 840 if blockchainMember != nil { 841 preparer = autorest.DecoratePreparer(preparer, 842 autorest.WithJSON(blockchainMember)) 843 } 844 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 845} 846 847// UpdateSender sends the Update request. The method will close the 848// http.Response Body if it receives an error. 849func (client MembersClient) UpdateSender(req *http.Request) (*http.Response, error) { 850 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 851} 852 853// UpdateResponder handles the response to the Update request. The method always 854// closes the http.Response Body. 855func (client MembersClient) UpdateResponder(resp *http.Response) (result Member, err error) { 856 err = autorest.Respond( 857 resp, 858 azure.WithErrorUnlessStatusCode(http.StatusOK), 859 autorest.ByUnmarshallingJSON(&result), 860 autorest.ByClosing()) 861 result.Response = autorest.Response{Response: resp} 862 return 863} 864