...

Source file src/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network/serviceassociationlinks.go

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network

     1  package network
     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  // ServiceAssociationLinksClient is the network Client
    18  type ServiceAssociationLinksClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewServiceAssociationLinksClient creates an instance of the ServiceAssociationLinksClient client.
    23  func NewServiceAssociationLinksClient(subscriptionID string) ServiceAssociationLinksClient {
    24  	return NewServiceAssociationLinksClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewServiceAssociationLinksClientWithBaseURI creates an instance of the ServiceAssociationLinksClient client using a
    28  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    29  // Azure stack).
    30  func NewServiceAssociationLinksClientWithBaseURI(baseURI string, subscriptionID string) ServiceAssociationLinksClient {
    31  	return ServiceAssociationLinksClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // List gets a list of service association links for a subnet.
    35  // Parameters:
    36  // resourceGroupName - the name of the resource group.
    37  // virtualNetworkName - the name of the virtual network.
    38  // subnetName - the name of the subnet.
    39  func (client ServiceAssociationLinksClient) List(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (result ServiceAssociationLinksListResult, err error) {
    40  	if tracing.IsEnabled() {
    41  		ctx = tracing.StartSpan(ctx, fqdn+"/ServiceAssociationLinksClient.List")
    42  		defer func() {
    43  			sc := -1
    44  			if result.Response.Response != nil {
    45  				sc = result.Response.Response.StatusCode
    46  			}
    47  			tracing.EndSpan(ctx, sc, err)
    48  		}()
    49  	}
    50  	req, err := client.ListPreparer(ctx, resourceGroupName, virtualNetworkName, subnetName)
    51  	if err != nil {
    52  		err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", nil, "Failure preparing request")
    53  		return
    54  	}
    55  
    56  	resp, err := client.ListSender(req)
    57  	if err != nil {
    58  		result.Response = autorest.Response{Response: resp}
    59  		err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", resp, "Failure sending request")
    60  		return
    61  	}
    62  
    63  	result, err = client.ListResponder(resp)
    64  	if err != nil {
    65  		err = autorest.NewErrorWithError(err, "network.ServiceAssociationLinksClient", "List", resp, "Failure responding to request")
    66  		return
    67  	}
    68  
    69  	return
    70  }
    71  
    72  // ListPreparer prepares the List request.
    73  func (client ServiceAssociationLinksClient) ListPreparer(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string) (*http.Request, error) {
    74  	pathParameters := map[string]interface{}{
    75  		"resourceGroupName":  autorest.Encode("path", resourceGroupName),
    76  		"subnetName":         autorest.Encode("path", subnetName),
    77  		"subscriptionId":     autorest.Encode("path", client.SubscriptionID),
    78  		"virtualNetworkName": autorest.Encode("path", virtualNetworkName),
    79  	}
    80  
    81  	const APIVersion = "2021-08-01"
    82  	queryParameters := map[string]interface{}{
    83  		"api-version": APIVersion,
    84  	}
    85  
    86  	preparer := autorest.CreatePreparer(
    87  		autorest.AsGet(),
    88  		autorest.WithBaseURL(client.BaseURI),
    89  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/ServiceAssociationLinks", pathParameters),
    90  		autorest.WithQueryParameters(queryParameters))
    91  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    92  }
    93  
    94  // ListSender sends the List request. The method will close the
    95  // http.Response Body if it receives an error.
    96  func (client ServiceAssociationLinksClient) ListSender(req *http.Request) (*http.Response, error) {
    97  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    98  }
    99  
   100  // ListResponder handles the response to the List request. The method always
   101  // closes the http.Response Body.
   102  func (client ServiceAssociationLinksClient) ListResponder(resp *http.Response) (result ServiceAssociationLinksListResult, err error) {
   103  	err = autorest.Respond(
   104  		resp,
   105  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   106  		autorest.ByUnmarshallingJSON(&result),
   107  		autorest.ByClosing())
   108  	result.Response = autorest.Response{Response: resp}
   109  	return
   110  }
   111  

View as plain text