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// AvailableResourceGroupDelegationsClient is the network Client 29type AvailableResourceGroupDelegationsClient struct { 30 BaseClient 31} 32 33// NewAvailableResourceGroupDelegationsClient creates an instance of the AvailableResourceGroupDelegationsClient 34// client. 35func NewAvailableResourceGroupDelegationsClient(subscriptionID string) AvailableResourceGroupDelegationsClient { 36 return NewAvailableResourceGroupDelegationsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewAvailableResourceGroupDelegationsClientWithBaseURI creates an instance of the 40// AvailableResourceGroupDelegationsClient client. 41func NewAvailableResourceGroupDelegationsClientWithBaseURI(baseURI string, subscriptionID string) AvailableResourceGroupDelegationsClient { 42 return AvailableResourceGroupDelegationsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// List gets all of the available subnet delegations for this resource group in this region. 46// Parameters: 47// location - the location of the domain name. 48// resourceGroupName - the name of the resource group. 49func (client AvailableResourceGroupDelegationsClient) List(ctx context.Context, location string, resourceGroupName string) (result AvailableDelegationsResultPage, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/AvailableResourceGroupDelegationsClient.List") 52 defer func() { 53 sc := -1 54 if result.adr.Response.Response != nil { 55 sc = result.adr.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 result.fn = client.listNextResults 61 req, err := client.ListPreparer(ctx, location, resourceGroupName) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "List", nil, "Failure preparing request") 64 return 65 } 66 67 resp, err := client.ListSender(req) 68 if err != nil { 69 result.adr.Response = autorest.Response{Response: resp} 70 err = autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "List", resp, "Failure sending request") 71 return 72 } 73 74 result.adr, err = client.ListResponder(resp) 75 if err != nil { 76 err = autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "List", resp, "Failure responding to request") 77 } 78 79 return 80} 81 82// ListPreparer prepares the List request. 83func (client AvailableResourceGroupDelegationsClient) ListPreparer(ctx context.Context, location string, resourceGroupName string) (*http.Request, error) { 84 pathParameters := map[string]interface{}{ 85 "location": autorest.Encode("path", location), 86 "resourceGroupName": autorest.Encode("path", resourceGroupName), 87 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 88 } 89 90 const APIVersion = "2018-10-01" 91 queryParameters := map[string]interface{}{ 92 "api-version": APIVersion, 93 } 94 95 preparer := autorest.CreatePreparer( 96 autorest.AsGet(), 97 autorest.WithBaseURL(client.BaseURI), 98 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/locations/{location}/availableDelegations", pathParameters), 99 autorest.WithQueryParameters(queryParameters)) 100 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 101} 102 103// ListSender sends the List request. The method will close the 104// http.Response Body if it receives an error. 105func (client AvailableResourceGroupDelegationsClient) ListSender(req *http.Request) (*http.Response, error) { 106 return autorest.SendWithSender(client, req, 107 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 AvailableResourceGroupDelegationsClient) ListResponder(resp *http.Response) (result AvailableDelegationsResult, 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 123// listNextResults retrieves the next set of results, if any. 124func (client AvailableResourceGroupDelegationsClient) listNextResults(ctx context.Context, lastResults AvailableDelegationsResult) (result AvailableDelegationsResult, err error) { 125 req, err := lastResults.availableDelegationsResultPreparer(ctx) 126 if err != nil { 127 return result, autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "listNextResults", nil, "Failure preparing next results request") 128 } 129 if req == nil { 130 return 131 } 132 resp, err := client.ListSender(req) 133 if err != nil { 134 result.Response = autorest.Response{Response: resp} 135 return result, autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "listNextResults", resp, "Failure sending next results request") 136 } 137 result, err = client.ListResponder(resp) 138 if err != nil { 139 err = autorest.NewErrorWithError(err, "network.AvailableResourceGroupDelegationsClient", "listNextResults", resp, "Failure responding to next results request") 140 } 141 return 142} 143 144// ListComplete enumerates all values, automatically crossing page boundaries as required. 145func (client AvailableResourceGroupDelegationsClient) ListComplete(ctx context.Context, location string, resourceGroupName string) (result AvailableDelegationsResultIterator, err error) { 146 if tracing.IsEnabled() { 147 ctx = tracing.StartSpan(ctx, fqdn+"/AvailableResourceGroupDelegationsClient.List") 148 defer func() { 149 sc := -1 150 if result.Response().Response.Response != nil { 151 sc = result.page.Response().Response.Response.StatusCode 152 } 153 tracing.EndSpan(ctx, sc, err) 154 }() 155 } 156 result.page, err = client.List(ctx, location, resourceGroupName) 157 return 158} 159