1// Package network implements the Azure ARM Network service API version 2// 2016-09-01. 3// 4// The Microsoft Azure Network management API provides a RESTful set of web 5// services that interact with Microsoft Azure Networks service to manage 6// your network resources. The API has entities that capture the relationship 7// between an end user and the Microsoft Azure Networks service. 8package network 9 10// Copyright (c) Microsoft and contributors. All rights reserved. 11// 12// Licensed under the Apache License, Version 2.0 (the "License"); 13// you may not use this file except in compliance with the License. 14// You may obtain a copy of the License at 15// http://www.apache.org/licenses/LICENSE-2.0 16// 17// Unless required by applicable law or agreed to in writing, software 18// distributed under the License is distributed on an "AS IS" BASIS, 19// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20// 21// See the License for the specific language governing permissions and 22// limitations under the License. 23// 24// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 25// Changes may cause incorrect behavior and will be lost if the code is 26// regenerated. 27 28import ( 29 "github.com/Azure/go-autorest/autorest" 30 "github.com/Azure/go-autorest/autorest/azure" 31 "net/http" 32) 33 34const ( 35 // APIVersion is the version of the Network 36 APIVersion = "2016-09-01" 37 38 // DefaultBaseURI is the default URI used for the service Network 39 DefaultBaseURI = "https://management.azure.com" 40) 41 42// ManagementClient is the base client for Network. 43type ManagementClient struct { 44 autorest.Client 45 BaseURI string 46 APIVersion string 47 SubscriptionID string 48} 49 50// New creates an instance of the ManagementClient client. 51func New(subscriptionID string) ManagementClient { 52 return NewWithBaseURI(DefaultBaseURI, subscriptionID) 53} 54 55// NewWithBaseURI creates an instance of the ManagementClient client. 56func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { 57 return ManagementClient{ 58 Client: autorest.NewClientWithUserAgent(UserAgent()), 59 BaseURI: baseURI, 60 APIVersion: APIVersion, 61 SubscriptionID: subscriptionID, 62 } 63} 64 65// CheckDNSNameAvailability checks whether a domain name in the cloudapp.net 66// zone is available for use. 67// 68// location is the location of the domain name domainNameLabel is the domain 69// name to be verified. It must conform to the following regular expression: 70// ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. 71func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { 72 req, err := client.CheckDNSNameAvailabilityPreparer(location, domainNameLabel) 73 if err != nil { 74 return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", nil, "Failure preparing request") 75 } 76 77 resp, err := client.CheckDNSNameAvailabilitySender(req) 78 if err != nil { 79 result.Response = autorest.Response{Response: resp} 80 return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure sending request") 81 } 82 83 result, err = client.CheckDNSNameAvailabilityResponder(resp) 84 if err != nil { 85 err = autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure responding to request") 86 } 87 88 return 89} 90 91// CheckDNSNameAvailabilityPreparer prepares the CheckDNSNameAvailability request. 92func (client ManagementClient) CheckDNSNameAvailabilityPreparer(location string, domainNameLabel string) (*http.Request, error) { 93 pathParameters := map[string]interface{}{ 94 "location": autorest.Encode("path", location), 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 } 97 98 queryParameters := map[string]interface{}{ 99 "api-version": client.APIVersion, 100 } 101 if len(domainNameLabel) > 0 { 102 queryParameters["domainNameLabel"] = autorest.Encode("query", domainNameLabel) 103 } 104 105 preparer := autorest.CreatePreparer( 106 autorest.AsGet(), 107 autorest.WithBaseURL(client.BaseURI), 108 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability", pathParameters), 109 autorest.WithQueryParameters(queryParameters)) 110 return preparer.Prepare(&http.Request{}) 111} 112 113// CheckDNSNameAvailabilitySender sends the CheckDNSNameAvailability request. The method will close the 114// http.Response Body if it receives an error. 115func (client ManagementClient) CheckDNSNameAvailabilitySender(req *http.Request) (*http.Response, error) { 116 return autorest.SendWithSender(client, req) 117} 118 119// CheckDNSNameAvailabilityResponder handles the response to the CheckDNSNameAvailability request. The method always 120// closes the http.Response Body. 121func (client ManagementClient) CheckDNSNameAvailabilityResponder(resp *http.Response) (result DNSNameAvailabilityResult, err error) { 122 err = autorest.Respond( 123 resp, 124 client.ByInspecting(), 125 azure.WithErrorUnlessStatusCode(http.StatusOK), 126 autorest.ByUnmarshallingJSON(&result), 127 autorest.ByClosing()) 128 result.Response = autorest.Response{Response: resp} 129 return 130} 131