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