1package 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 9import ( 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// PrivateDNSZoneGroupsClient is the network Client 18type PrivateDNSZoneGroupsClient struct { 19 BaseClient 20} 21 22// NewPrivateDNSZoneGroupsClient creates an instance of the PrivateDNSZoneGroupsClient client. 23func NewPrivateDNSZoneGroupsClient(subscriptionID string) PrivateDNSZoneGroupsClient { 24 return NewPrivateDNSZoneGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewPrivateDNSZoneGroupsClientWithBaseURI creates an instance of the PrivateDNSZoneGroupsClient client using a custom 28// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 29// stack). 30func NewPrivateDNSZoneGroupsClientWithBaseURI(baseURI string, subscriptionID string) PrivateDNSZoneGroupsClient { 31 return PrivateDNSZoneGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates a private dns zone group in the specified private endpoint. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// privateEndpointName - the name of the private endpoint. 38// privateDNSZoneGroupName - the name of the private dns zone group. 39// parameters - parameters supplied to the create or update private dns zone group operation. 40func (client PrivateDNSZoneGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, parameters PrivateDNSZoneGroup) (result PrivateDNSZoneGroupsCreateOrUpdateFuture, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateDNSZoneGroupsClient.CreateOrUpdate") 43 defer func() { 44 sc := -1 45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 46 sc = result.FutureAPI.Response().StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, privateEndpointName, privateDNSZoneGroupName, parameters) 52 if err != nil { 53 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") 54 return 55 } 56 57 result, err = client.CreateOrUpdateSender(req) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "CreateOrUpdate", nil, "Failure sending request") 60 return 61 } 62 63 return 64} 65 66// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 67func (client PrivateDNSZoneGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, parameters PrivateDNSZoneGroup) (*http.Request, error) { 68 pathParameters := map[string]interface{}{ 69 "privateDnsZoneGroupName": autorest.Encode("path", privateDNSZoneGroupName), 70 "privateEndpointName": autorest.Encode("path", privateEndpointName), 71 "resourceGroupName": autorest.Encode("path", resourceGroupName), 72 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 73 } 74 75 const APIVersion = "2020-11-01" 76 queryParameters := map[string]interface{}{ 77 "api-version": APIVersion, 78 } 79 80 parameters.Etag = nil 81 preparer := autorest.CreatePreparer( 82 autorest.AsContentType("application/json; charset=utf-8"), 83 autorest.AsPut(), 84 autorest.WithBaseURL(client.BaseURI), 85 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}", pathParameters), 86 autorest.WithJSON(parameters), 87 autorest.WithQueryParameters(queryParameters)) 88 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 89} 90 91// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 92// http.Response Body if it receives an error. 93func (client PrivateDNSZoneGroupsClient) CreateOrUpdateSender(req *http.Request) (future PrivateDNSZoneGroupsCreateOrUpdateFuture, err error) { 94 var resp *http.Response 95 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 96 if err != nil { 97 return 98 } 99 var azf azure.Future 100 azf, err = azure.NewFutureFromResponse(resp) 101 future.FutureAPI = &azf 102 future.Result = future.result 103 return 104} 105 106// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 107// closes the http.Response Body. 108func (client PrivateDNSZoneGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateDNSZoneGroup, err error) { 109 err = autorest.Respond( 110 resp, 111 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 112 autorest.ByUnmarshallingJSON(&result), 113 autorest.ByClosing()) 114 result.Response = autorest.Response{Response: resp} 115 return 116} 117 118// Delete deletes the specified private dns zone group. 119// Parameters: 120// resourceGroupName - the name of the resource group. 121// privateEndpointName - the name of the private endpoint. 122// privateDNSZoneGroupName - the name of the private dns zone group. 123func (client PrivateDNSZoneGroupsClient) Delete(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string) (result PrivateDNSZoneGroupsDeleteFuture, err error) { 124 if tracing.IsEnabled() { 125 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateDNSZoneGroupsClient.Delete") 126 defer func() { 127 sc := -1 128 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 129 sc = result.FutureAPI.Response().StatusCode 130 } 131 tracing.EndSpan(ctx, sc, err) 132 }() 133 } 134 req, err := client.DeletePreparer(ctx, resourceGroupName, privateEndpointName, privateDNSZoneGroupName) 135 if err != nil { 136 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "Delete", nil, "Failure preparing request") 137 return 138 } 139 140 result, err = client.DeleteSender(req) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "Delete", nil, "Failure sending request") 143 return 144 } 145 146 return 147} 148 149// DeletePreparer prepares the Delete request. 150func (client PrivateDNSZoneGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string) (*http.Request, error) { 151 pathParameters := map[string]interface{}{ 152 "privateDnsZoneGroupName": autorest.Encode("path", privateDNSZoneGroupName), 153 "privateEndpointName": autorest.Encode("path", privateEndpointName), 154 "resourceGroupName": autorest.Encode("path", resourceGroupName), 155 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 156 } 157 158 const APIVersion = "2020-11-01" 159 queryParameters := map[string]interface{}{ 160 "api-version": APIVersion, 161 } 162 163 preparer := autorest.CreatePreparer( 164 autorest.AsDelete(), 165 autorest.WithBaseURL(client.BaseURI), 166 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}", pathParameters), 167 autorest.WithQueryParameters(queryParameters)) 168 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 169} 170 171// DeleteSender sends the Delete request. The method will close the 172// http.Response Body if it receives an error. 173func (client PrivateDNSZoneGroupsClient) DeleteSender(req *http.Request) (future PrivateDNSZoneGroupsDeleteFuture, err error) { 174 var resp *http.Response 175 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 176 if err != nil { 177 return 178 } 179 var azf azure.Future 180 azf, err = azure.NewFutureFromResponse(resp) 181 future.FutureAPI = &azf 182 future.Result = future.result 183 return 184} 185 186// DeleteResponder handles the response to the Delete request. The method always 187// closes the http.Response Body. 188func (client PrivateDNSZoneGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 189 err = autorest.Respond( 190 resp, 191 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 192 autorest.ByClosing()) 193 result.Response = resp 194 return 195} 196 197// Get gets the private dns zone group resource by specified private dns zone group name. 198// Parameters: 199// resourceGroupName - the name of the resource group. 200// privateEndpointName - the name of the private endpoint. 201// privateDNSZoneGroupName - the name of the private dns zone group. 202func (client PrivateDNSZoneGroupsClient) Get(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string) (result PrivateDNSZoneGroup, err error) { 203 if tracing.IsEnabled() { 204 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateDNSZoneGroupsClient.Get") 205 defer func() { 206 sc := -1 207 if result.Response.Response != nil { 208 sc = result.Response.Response.StatusCode 209 } 210 tracing.EndSpan(ctx, sc, err) 211 }() 212 } 213 req, err := client.GetPreparer(ctx, resourceGroupName, privateEndpointName, privateDNSZoneGroupName) 214 if err != nil { 215 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "Get", nil, "Failure preparing request") 216 return 217 } 218 219 resp, err := client.GetSender(req) 220 if err != nil { 221 result.Response = autorest.Response{Response: resp} 222 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "Get", resp, "Failure sending request") 223 return 224 } 225 226 result, err = client.GetResponder(resp) 227 if err != nil { 228 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "Get", resp, "Failure responding to request") 229 return 230 } 231 232 return 233} 234 235// GetPreparer prepares the Get request. 236func (client PrivateDNSZoneGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string) (*http.Request, error) { 237 pathParameters := map[string]interface{}{ 238 "privateDnsZoneGroupName": autorest.Encode("path", privateDNSZoneGroupName), 239 "privateEndpointName": autorest.Encode("path", privateEndpointName), 240 "resourceGroupName": autorest.Encode("path", resourceGroupName), 241 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 242 } 243 244 const APIVersion = "2020-11-01" 245 queryParameters := map[string]interface{}{ 246 "api-version": APIVersion, 247 } 248 249 preparer := autorest.CreatePreparer( 250 autorest.AsGet(), 251 autorest.WithBaseURL(client.BaseURI), 252 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}", pathParameters), 253 autorest.WithQueryParameters(queryParameters)) 254 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 255} 256 257// GetSender sends the Get request. The method will close the 258// http.Response Body if it receives an error. 259func (client PrivateDNSZoneGroupsClient) GetSender(req *http.Request) (*http.Response, error) { 260 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 261} 262 263// GetResponder handles the response to the Get request. The method always 264// closes the http.Response Body. 265func (client PrivateDNSZoneGroupsClient) GetResponder(resp *http.Response) (result PrivateDNSZoneGroup, err error) { 266 err = autorest.Respond( 267 resp, 268 azure.WithErrorUnlessStatusCode(http.StatusOK), 269 autorest.ByUnmarshallingJSON(&result), 270 autorest.ByClosing()) 271 result.Response = autorest.Response{Response: resp} 272 return 273} 274 275// List gets all private dns zone groups in a private endpoint. 276// Parameters: 277// privateEndpointName - the name of the private endpoint. 278// resourceGroupName - the name of the resource group. 279func (client PrivateDNSZoneGroupsClient) List(ctx context.Context, privateEndpointName string, resourceGroupName string) (result PrivateDNSZoneGroupListResultPage, err error) { 280 if tracing.IsEnabled() { 281 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateDNSZoneGroupsClient.List") 282 defer func() { 283 sc := -1 284 if result.pdzglr.Response.Response != nil { 285 sc = result.pdzglr.Response.Response.StatusCode 286 } 287 tracing.EndSpan(ctx, sc, err) 288 }() 289 } 290 result.fn = client.listNextResults 291 req, err := client.ListPreparer(ctx, privateEndpointName, resourceGroupName) 292 if err != nil { 293 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "List", nil, "Failure preparing request") 294 return 295 } 296 297 resp, err := client.ListSender(req) 298 if err != nil { 299 result.pdzglr.Response = autorest.Response{Response: resp} 300 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "List", resp, "Failure sending request") 301 return 302 } 303 304 result.pdzglr, err = client.ListResponder(resp) 305 if err != nil { 306 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "List", resp, "Failure responding to request") 307 return 308 } 309 if result.pdzglr.hasNextLink() && result.pdzglr.IsEmpty() { 310 err = result.NextWithContext(ctx) 311 return 312 } 313 314 return 315} 316 317// ListPreparer prepares the List request. 318func (client PrivateDNSZoneGroupsClient) ListPreparer(ctx context.Context, privateEndpointName string, resourceGroupName string) (*http.Request, error) { 319 pathParameters := map[string]interface{}{ 320 "privateEndpointName": autorest.Encode("path", privateEndpointName), 321 "resourceGroupName": autorest.Encode("path", resourceGroupName), 322 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 323 } 324 325 const APIVersion = "2020-11-01" 326 queryParameters := map[string]interface{}{ 327 "api-version": APIVersion, 328 } 329 330 preparer := autorest.CreatePreparer( 331 autorest.AsGet(), 332 autorest.WithBaseURL(client.BaseURI), 333 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups", pathParameters), 334 autorest.WithQueryParameters(queryParameters)) 335 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 336} 337 338// ListSender sends the List request. The method will close the 339// http.Response Body if it receives an error. 340func (client PrivateDNSZoneGroupsClient) ListSender(req *http.Request) (*http.Response, error) { 341 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 342} 343 344// ListResponder handles the response to the List request. The method always 345// closes the http.Response Body. 346func (client PrivateDNSZoneGroupsClient) ListResponder(resp *http.Response) (result PrivateDNSZoneGroupListResult, err error) { 347 err = autorest.Respond( 348 resp, 349 azure.WithErrorUnlessStatusCode(http.StatusOK), 350 autorest.ByUnmarshallingJSON(&result), 351 autorest.ByClosing()) 352 result.Response = autorest.Response{Response: resp} 353 return 354} 355 356// listNextResults retrieves the next set of results, if any. 357func (client PrivateDNSZoneGroupsClient) listNextResults(ctx context.Context, lastResults PrivateDNSZoneGroupListResult) (result PrivateDNSZoneGroupListResult, err error) { 358 req, err := lastResults.privateDNSZoneGroupListResultPreparer(ctx) 359 if err != nil { 360 return result, autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "listNextResults", nil, "Failure preparing next results request") 361 } 362 if req == nil { 363 return 364 } 365 resp, err := client.ListSender(req) 366 if err != nil { 367 result.Response = autorest.Response{Response: resp} 368 return result, autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "listNextResults", resp, "Failure sending next results request") 369 } 370 result, err = client.ListResponder(resp) 371 if err != nil { 372 err = autorest.NewErrorWithError(err, "network.PrivateDNSZoneGroupsClient", "listNextResults", resp, "Failure responding to next results request") 373 } 374 return 375} 376 377// ListComplete enumerates all values, automatically crossing page boundaries as required. 378func (client PrivateDNSZoneGroupsClient) ListComplete(ctx context.Context, privateEndpointName string, resourceGroupName string) (result PrivateDNSZoneGroupListResultIterator, err error) { 379 if tracing.IsEnabled() { 380 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateDNSZoneGroupsClient.List") 381 defer func() { 382 sc := -1 383 if result.Response().Response.Response != nil { 384 sc = result.page.Response().Response.Response.StatusCode 385 } 386 tracing.EndSpan(ctx, sc, err) 387 }() 388 } 389 result.page, err = client.List(ctx, privateEndpointName, resourceGroupName) 390 return 391} 392