1package netapp 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/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// MountTargetsClient is the microsoft NetApp Azure Resource Provider specification 19type MountTargetsClient struct { 20 BaseClient 21} 22 23// NewMountTargetsClient creates an instance of the MountTargetsClient client. 24func NewMountTargetsClient(subscriptionID string) MountTargetsClient { 25 return NewMountTargetsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewMountTargetsClientWithBaseURI creates an instance of the MountTargetsClient client using a custom endpoint. Use 29// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewMountTargetsClientWithBaseURI(baseURI string, subscriptionID string) MountTargetsClient { 31 return MountTargetsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// List list all mount targets associated with the volume 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// accountName - the name of the NetApp account 38// poolName - the name of the capacity pool 39// volumeName - the name of the volume 40func (client MountTargetsClient) List(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (result MountTargetList, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/MountTargetsClient.List") 43 defer func() { 44 sc := -1 45 if result.Response.Response != nil { 46 sc = result.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: resourceGroupName, 53 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 54 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 55 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 56 return result, validation.NewError("netapp.MountTargetsClient", "List", err.Error()) 57 } 58 59 req, err := client.ListPreparer(ctx, resourceGroupName, accountName, poolName, volumeName) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.ListSender(req) 66 if err != nil { 67 result.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.ListResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "netapp.MountTargetsClient", "List", resp, "Failure responding to request") 75 return 76 } 77 78 return 79} 80 81// ListPreparer prepares the List request. 82func (client MountTargetsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string, poolName string, volumeName string) (*http.Request, error) { 83 pathParameters := map[string]interface{}{ 84 "accountName": autorest.Encode("path", accountName), 85 "poolName": autorest.Encode("path", poolName), 86 "resourceGroupName": autorest.Encode("path", resourceGroupName), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 "volumeName": autorest.Encode("path", volumeName), 89 } 90 91 const APIVersion = "2019-10-01" 92 queryParameters := map[string]interface{}{ 93 "api-version": APIVersion, 94 } 95 96 preparer := autorest.CreatePreparer( 97 autorest.AsGet(), 98 autorest.WithBaseURL(client.BaseURI), 99 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/mountTargets", pathParameters), 100 autorest.WithQueryParameters(queryParameters)) 101 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 102} 103 104// ListSender sends the List request. The method will close the 105// http.Response Body if it receives an error. 106func (client MountTargetsClient) ListSender(req *http.Request) (*http.Response, error) { 107 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 108} 109 110// ListResponder handles the response to the List request. The method always 111// closes the http.Response Body. 112func (client MountTargetsClient) ListResponder(resp *http.Response) (result MountTargetList, err error) { 113 err = autorest.Respond( 114 resp, 115 azure.WithErrorUnlessStatusCode(http.StatusOK), 116 autorest.ByUnmarshallingJSON(&result), 117 autorest.ByClosing()) 118 result.Response = autorest.Response{Response: resp} 119 return 120} 121