1// Package network implements the Azure ARM Network service API version . 2// 3// Network Client 4package network 5 6// Copyright (c) Microsoft Corporation. All rights reserved. 7// Licensed under the MIT License. See License.txt in the project root for license information. 8// 9// Code generated by Microsoft (R) AutoRest Code Generator. 10// Changes may cause incorrect behavior and will be lost if the code is regenerated. 11 12import ( 13 "context" 14 "github.com/Azure/go-autorest/autorest" 15 "github.com/Azure/go-autorest/autorest/azure" 16 "github.com/Azure/go-autorest/tracing" 17 "net/http" 18) 19 20const ( 21 // DefaultBaseURI is the default URI used for the service Network 22 DefaultBaseURI = "https://management.azure.com" 23) 24 25// BaseClient is the base client for Network. 26type BaseClient struct { 27 autorest.Client 28 BaseURI string 29 SubscriptionID string 30} 31 32// New creates an instance of the BaseClient client. 33func New(subscriptionID string) BaseClient { 34 return NewWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with 38// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 39func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { 40 return BaseClient{ 41 Client: autorest.NewClientWithUserAgent(UserAgent()), 42 BaseURI: baseURI, 43 SubscriptionID: subscriptionID, 44 } 45} 46 47// CheckDNSNameAvailability checks whether a domain name in the cloudapp.azure.com zone is available for use. 48// Parameters: 49// location - the location of the domain name. 50// domainNameLabel - the domain name to be verified. It must conform to the following regular expression: 51// ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. 52func (client BaseClient) CheckDNSNameAvailability(ctx context.Context, location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.CheckDNSNameAvailability") 55 defer func() { 56 sc := -1 57 if result.Response.Response != nil { 58 sc = result.Response.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 req, err := client.CheckDNSNameAvailabilityPreparer(ctx, location, domainNameLabel) 64 if err != nil { 65 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", nil, "Failure preparing request") 66 return 67 } 68 69 resp, err := client.CheckDNSNameAvailabilitySender(req) 70 if err != nil { 71 result.Response = autorest.Response{Response: resp} 72 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", resp, "Failure sending request") 73 return 74 } 75 76 result, err = client.CheckDNSNameAvailabilityResponder(resp) 77 if err != nil { 78 err = autorest.NewErrorWithError(err, "network.BaseClient", "CheckDNSNameAvailability", resp, "Failure responding to request") 79 return 80 } 81 82 return 83} 84 85// CheckDNSNameAvailabilityPreparer prepares the CheckDNSNameAvailability request. 86func (client BaseClient) CheckDNSNameAvailabilityPreparer(ctx context.Context, location string, domainNameLabel string) (*http.Request, error) { 87 pathParameters := map[string]interface{}{ 88 "location": autorest.Encode("path", location), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 } 91 92 const APIVersion = "2019-08-01" 93 queryParameters := map[string]interface{}{ 94 "api-version": APIVersion, 95 "domainNameLabel": autorest.Encode("query", domainNameLabel), 96 } 97 98 preparer := autorest.CreatePreparer( 99 autorest.AsGet(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability", pathParameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// CheckDNSNameAvailabilitySender sends the CheckDNSNameAvailability request. The method will close the 107// http.Response Body if it receives an error. 108func (client BaseClient) CheckDNSNameAvailabilitySender(req *http.Request) (*http.Response, error) { 109 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 110} 111 112// CheckDNSNameAvailabilityResponder handles the response to the CheckDNSNameAvailability request. The method always 113// closes the http.Response Body. 114func (client BaseClient) CheckDNSNameAvailabilityResponder(resp *http.Response) (result DNSNameAvailabilityResult, err error) { 115 err = autorest.Respond( 116 resp, 117 azure.WithErrorUnlessStatusCode(http.StatusOK), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// Generatevirtualwanvpnserverconfigurationvpnprofile generates a unique VPN profile for P2S clients for VirtualWan and 125// associated VpnServerConfiguration combination in the specified resource group. 126// Parameters: 127// resourceGroupName - the resource group name. 128// virtualWANName - the name of the VirtualWAN whose associated VpnServerConfigurations is needed. 129// vpnClientParams - parameters supplied to the generate VirtualWan VPN profile generation operation. 130func (client BaseClient) Generatevirtualwanvpnserverconfigurationvpnprofile(ctx context.Context, resourceGroupName string, virtualWANName string, vpnClientParams VirtualWanVpnProfileParameters) (result GeneratevirtualwanvpnserverconfigurationvpnprofileFuture, err error) { 131 if tracing.IsEnabled() { 132 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.Generatevirtualwanvpnserverconfigurationvpnprofile") 133 defer func() { 134 sc := -1 135 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 136 sc = result.FutureAPI.Response().StatusCode 137 } 138 tracing.EndSpan(ctx, sc, err) 139 }() 140 } 141 req, err := client.GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer(ctx, resourceGroupName, virtualWANName, vpnClientParams) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "network.BaseClient", "Generatevirtualwanvpnserverconfigurationvpnprofile", nil, "Failure preparing request") 144 return 145 } 146 147 result, err = client.GeneratevirtualwanvpnserverconfigurationvpnprofileSender(req) 148 if err != nil { 149 err = autorest.NewErrorWithError(err, "network.BaseClient", "Generatevirtualwanvpnserverconfigurationvpnprofile", nil, "Failure sending request") 150 return 151 } 152 153 return 154} 155 156// GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer prepares the Generatevirtualwanvpnserverconfigurationvpnprofile request. 157func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofilePreparer(ctx context.Context, resourceGroupName string, virtualWANName string, vpnClientParams VirtualWanVpnProfileParameters) (*http.Request, error) { 158 pathParameters := map[string]interface{}{ 159 "resourceGroupName": autorest.Encode("path", resourceGroupName), 160 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 161 "virtualWANName": autorest.Encode("path", virtualWANName), 162 } 163 164 const APIVersion = "2019-08-01" 165 queryParameters := map[string]interface{}{ 166 "api-version": APIVersion, 167 } 168 169 preparer := autorest.CreatePreparer( 170 autorest.AsContentType("application/json; charset=utf-8"), 171 autorest.AsPost(), 172 autorest.WithBaseURL(client.BaseURI), 173 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/GenerateVpnProfile", pathParameters), 174 autorest.WithJSON(vpnClientParams), 175 autorest.WithQueryParameters(queryParameters)) 176 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 177} 178 179// GeneratevirtualwanvpnserverconfigurationvpnprofileSender sends the Generatevirtualwanvpnserverconfigurationvpnprofile request. The method will close the 180// http.Response Body if it receives an error. 181func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofileSender(req *http.Request) (future GeneratevirtualwanvpnserverconfigurationvpnprofileFuture, err error) { 182 var resp *http.Response 183 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 184 if err != nil { 185 return 186 } 187 var azf azure.Future 188 azf, err = azure.NewFutureFromResponse(resp) 189 future.FutureAPI = &azf 190 future.Result = future.result 191 return 192} 193 194// GeneratevirtualwanvpnserverconfigurationvpnprofileResponder handles the response to the Generatevirtualwanvpnserverconfigurationvpnprofile request. The method always 195// closes the http.Response Body. 196func (client BaseClient) GeneratevirtualwanvpnserverconfigurationvpnprofileResponder(resp *http.Response) (result VpnProfileResponse, err error) { 197 err = autorest.Respond( 198 resp, 199 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 200 autorest.ByUnmarshallingJSON(&result), 201 autorest.ByClosing()) 202 result.Response = autorest.Response{Response: resp} 203 return 204} 205 206// SupportedSecurityProviders gives the supported security providers for the virtual wan. 207// Parameters: 208// resourceGroupName - the resource group name. 209// virtualWANName - the name of the VirtualWAN for which supported security providers are needed. 210func (client BaseClient) SupportedSecurityProviders(ctx context.Context, resourceGroupName string, virtualWANName string) (result VirtualWanSecurityProviders, err error) { 211 if tracing.IsEnabled() { 212 ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.SupportedSecurityProviders") 213 defer func() { 214 sc := -1 215 if result.Response.Response != nil { 216 sc = result.Response.Response.StatusCode 217 } 218 tracing.EndSpan(ctx, sc, err) 219 }() 220 } 221 req, err := client.SupportedSecurityProvidersPreparer(ctx, resourceGroupName, virtualWANName) 222 if err != nil { 223 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", nil, "Failure preparing request") 224 return 225 } 226 227 resp, err := client.SupportedSecurityProvidersSender(req) 228 if err != nil { 229 result.Response = autorest.Response{Response: resp} 230 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", resp, "Failure sending request") 231 return 232 } 233 234 result, err = client.SupportedSecurityProvidersResponder(resp) 235 if err != nil { 236 err = autorest.NewErrorWithError(err, "network.BaseClient", "SupportedSecurityProviders", resp, "Failure responding to request") 237 return 238 } 239 240 return 241} 242 243// SupportedSecurityProvidersPreparer prepares the SupportedSecurityProviders request. 244func (client BaseClient) SupportedSecurityProvidersPreparer(ctx context.Context, resourceGroupName string, virtualWANName string) (*http.Request, error) { 245 pathParameters := map[string]interface{}{ 246 "resourceGroupName": autorest.Encode("path", resourceGroupName), 247 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 248 "virtualWANName": autorest.Encode("path", virtualWANName), 249 } 250 251 const APIVersion = "2019-08-01" 252 queryParameters := map[string]interface{}{ 253 "api-version": APIVersion, 254 } 255 256 preparer := autorest.CreatePreparer( 257 autorest.AsGet(), 258 autorest.WithBaseURL(client.BaseURI), 259 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/supportedSecurityProviders", pathParameters), 260 autorest.WithQueryParameters(queryParameters)) 261 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 262} 263 264// SupportedSecurityProvidersSender sends the SupportedSecurityProviders request. The method will close the 265// http.Response Body if it receives an error. 266func (client BaseClient) SupportedSecurityProvidersSender(req *http.Request) (*http.Response, error) { 267 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 268} 269 270// SupportedSecurityProvidersResponder handles the response to the SupportedSecurityProviders request. The method always 271// closes the http.Response Body. 272func (client BaseClient) SupportedSecurityProvidersResponder(resp *http.Response) (result VirtualWanSecurityProviders, err error) { 273 err = autorest.Respond( 274 resp, 275 azure.WithErrorUnlessStatusCode(http.StatusOK), 276 autorest.ByUnmarshallingJSON(&result), 277 autorest.ByClosing()) 278 result.Response = autorest.Response{Response: resp} 279 return 280} 281