...

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

Documentation: github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-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  // AvailableEndpointServicesClient is the network Client
    18  type AvailableEndpointServicesClient struct {
    19  	BaseClient
    20  }
    21  
    22  // NewAvailableEndpointServicesClient creates an instance of the AvailableEndpointServicesClient client.
    23  func NewAvailableEndpointServicesClient(subscriptionID string) AvailableEndpointServicesClient {
    24  	return NewAvailableEndpointServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    25  }
    26  
    27  // NewAvailableEndpointServicesClientWithBaseURI creates an instance of the AvailableEndpointServicesClient client
    28  // using a custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign
    29  // clouds, Azure stack).
    30  func NewAvailableEndpointServicesClientWithBaseURI(baseURI string, subscriptionID string) AvailableEndpointServicesClient {
    31  	return AvailableEndpointServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // List list what values of endpoint services are available for use.
    35  // Parameters:
    36  // location - the location to check available endpoint services.
    37  func (client AvailableEndpointServicesClient) List(ctx context.Context, location string) (result EndpointServicesListResultPage, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/AvailableEndpointServicesClient.List")
    40  		defer func() {
    41  			sc := -1
    42  			if result.eslr.Response.Response != nil {
    43  				sc = result.eslr.Response.Response.StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	result.fn = client.listNextResults
    49  	req, err := client.ListPreparer(ctx, location)
    50  	if err != nil {
    51  		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", nil, "Failure preparing request")
    52  		return
    53  	}
    54  
    55  	resp, err := client.ListSender(req)
    56  	if err != nil {
    57  		result.eslr.Response = autorest.Response{Response: resp}
    58  		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure sending request")
    59  		return
    60  	}
    61  
    62  	result.eslr, err = client.ListResponder(resp)
    63  	if err != nil {
    64  		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "List", resp, "Failure responding to request")
    65  		return
    66  	}
    67  	if result.eslr.hasNextLink() && result.eslr.IsEmpty() {
    68  		err = result.NextWithContext(ctx)
    69  		return
    70  	}
    71  
    72  	return
    73  }
    74  
    75  // ListPreparer prepares the List request.
    76  func (client AvailableEndpointServicesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
    77  	pathParameters := map[string]interface{}{
    78  		"location":       autorest.Encode("path", location),
    79  		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
    80  	}
    81  
    82  	const APIVersion = "2018-08-01"
    83  	queryParameters := map[string]interface{}{
    84  		"api-version": APIVersion,
    85  	}
    86  
    87  	preparer := autorest.CreatePreparer(
    88  		autorest.AsGet(),
    89  		autorest.WithBaseURL(client.BaseURI),
    90  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/virtualNetworkAvailableEndpointServices", pathParameters),
    91  		autorest.WithQueryParameters(queryParameters))
    92  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    93  }
    94  
    95  // ListSender sends the List request. The method will close the
    96  // http.Response Body if it receives an error.
    97  func (client AvailableEndpointServicesClient) ListSender(req *http.Request) (*http.Response, error) {
    98  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
    99  }
   100  
   101  // ListResponder handles the response to the List request. The method always
   102  // closes the http.Response Body.
   103  func (client AvailableEndpointServicesClient) ListResponder(resp *http.Response) (result EndpointServicesListResult, err error) {
   104  	err = autorest.Respond(
   105  		resp,
   106  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   107  		autorest.ByUnmarshallingJSON(&result),
   108  		autorest.ByClosing())
   109  	result.Response = autorest.Response{Response: resp}
   110  	return
   111  }
   112  
   113  // listNextResults retrieves the next set of results, if any.
   114  func (client AvailableEndpointServicesClient) listNextResults(ctx context.Context, lastResults EndpointServicesListResult) (result EndpointServicesListResult, err error) {
   115  	req, err := lastResults.endpointServicesListResultPreparer(ctx)
   116  	if err != nil {
   117  		return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", nil, "Failure preparing next results request")
   118  	}
   119  	if req == nil {
   120  		return
   121  	}
   122  	resp, err := client.ListSender(req)
   123  	if err != nil {
   124  		result.Response = autorest.Response{Response: resp}
   125  		return result, autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure sending next results request")
   126  	}
   127  	result, err = client.ListResponder(resp)
   128  	if err != nil {
   129  		err = autorest.NewErrorWithError(err, "network.AvailableEndpointServicesClient", "listNextResults", resp, "Failure responding to next results request")
   130  	}
   131  	return
   132  }
   133  
   134  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   135  func (client AvailableEndpointServicesClient) ListComplete(ctx context.Context, location string) (result EndpointServicesListResultIterator, err error) {
   136  	if tracing.IsEnabled() {
   137  		ctx = tracing.StartSpan(ctx, fqdn+"/AvailableEndpointServicesClient.List")
   138  		defer func() {
   139  			sc := -1
   140  			if result.Response().Response.Response != nil {
   141  				sc = result.page.Response().Response.Response.StatusCode
   142  			}
   143  			tracing.EndSpan(ctx, sc, err)
   144  		}()
   145  	}
   146  	result.page, err = client.List(ctx, location)
   147  	return
   148  }
   149  

View as plain text