PageRenderTime 28ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go

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