1package network 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// ResourceNavigationLinksClient is the network Client 29type ResourceNavigationLinksClient struct { 30 BaseClient 31} 32 33// NewResourceNavigationLinksClient creates an instance of the ResourceNavigationLinksClient client. 34func NewResourceNavigationLinksClient(subscriptionID string) ResourceNavigationLinksClient { 35 return NewResourceNavigationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewResourceNavigationLinksClientWithBaseURI creates an instance of the ResourceNavigationLinksClient client using a 39// custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, 40// Azure stack). 41func NewResourceNavigationLinksClientWithBaseURI(baseURI string, subscriptionID string) ResourceNavigationLinksClient { 42 return ResourceNavigationLinksClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// List gets a list of resource navigation links for a subnet. 46// Parameters: 47// resourceGroupName - the name of the resource group. 48// virtualNetworkName - the name of the virtual network. 49// subnetName - the name of the subnet. 50func (client ResourceNavigationLinksClient) List(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (result ResourceNavigationLinksListResult, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/ResourceNavigationLinksClient.List") 53 defer func() { 54 sc := -1 55 if result.Response.Response != nil { 56 sc = result.Response.Response.StatusCode 57 } 58 tracing.EndSpan(ctx, sc, err) 59 }() 60 } 61 req, err := client.ListPreparer(ctx, resourceGroupName, virtualNetworkName, subnetName) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "network.ResourceNavigationLinksClient", "List", nil, "Failure preparing request") 64 return 65 } 66 67 resp, err := client.ListSender(req) 68 if err != nil { 69 result.Response = autorest.Response{Response: resp} 70 err = autorest.NewErrorWithError(err, "network.ResourceNavigationLinksClient", "List", resp, "Failure sending request") 71 return 72 } 73 74 result, err = client.ListResponder(resp) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "network.ResourceNavigationLinksClient", "List", resp, "Failure responding to request") 77 } 78 79 return 80} 81 82// ListPreparer prepares the List request. 83func (client ResourceNavigationLinksClient) ListPreparer(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (*http.Request, error) { 84 pathParameters := map[string]interface{}{ 85 "resourceGroupName": autorest.Encode("path", resourceGroupName), 86 "subnetName": autorest.Encode("path", subnetName), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 "virtualNetworkName": autorest.Encode("path", virtualNetworkName), 89 } 90 91 const APIVersion = "2020-05-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.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/ResourceNavigationLinks", 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 ResourceNavigationLinksClient) 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 ResourceNavigationLinksClient) ListResponder(resp *http.Response) (result ResourceNavigationLinksListResult, err error) { 113 err = autorest.Respond( 114 resp, 115 client.ByInspecting(), 116 azure.WithErrorUnlessStatusCode(http.StatusOK), 117 autorest.ByUnmarshallingJSON(&result), 118 autorest.ByClosing()) 119 result.Response = autorest.Response{Response: resp} 120 return 121} 122