...

Source file src/github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers/getprivatednszonesuffix.go

Documentation: github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2021-06-01/postgresqlflexibleservers

     1  package postgresqlflexibleservers
     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  
     9  import (
    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  // GetPrivateDNSZoneSuffixClient is the the Microsoft Azure management API provides create, read, update, and delete
    18  // functionality for Azure PostgreSQL resources including servers, databases, firewall rules, VNET rules, security
    19  // alert policies, log files and configurations with new business model.
    20  type GetPrivateDNSZoneSuffixClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewGetPrivateDNSZoneSuffixClient creates an instance of the GetPrivateDNSZoneSuffixClient client.
    25  func NewGetPrivateDNSZoneSuffixClient(subscriptionID string) GetPrivateDNSZoneSuffixClient {
    26  	return NewGetPrivateDNSZoneSuffixClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewGetPrivateDNSZoneSuffixClientWithBaseURI creates an instance of the GetPrivateDNSZoneSuffixClient client using a
    30  // custom endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds,
    31  // Azure stack).
    32  func NewGetPrivateDNSZoneSuffixClientWithBaseURI(baseURI string, subscriptionID string) GetPrivateDNSZoneSuffixClient {
    33  	return GetPrivateDNSZoneSuffixClient{NewWithBaseURI(baseURI, subscriptionID)}
    34  }
    35  
    36  // Execute get private DNS zone suffix in the cloud
    37  func (client GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context) (result String, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/GetPrivateDNSZoneSuffixClient.Execute")
    40  		defer func() {
    41  			sc := -1
    42  			if result.Response.Response != nil {
    43  				sc = result.Response.Response.StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	req, err := client.ExecutePreparer(ctx)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	resp, err := client.ExecuteSender(req)
    55  	if err != nil {
    56  		result.Response = autorest.Response{Response: resp}
    57  		err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure sending request")
    58  		return
    59  	}
    60  
    61  	result, err = client.ExecuteResponder(resp)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "postgresqlflexibleservers.GetPrivateDNSZoneSuffixClient", "Execute", resp, "Failure responding to request")
    64  		return
    65  	}
    66  
    67  	return
    68  }
    69  
    70  // ExecutePreparer prepares the Execute request.
    71  func (client GetPrivateDNSZoneSuffixClient) ExecutePreparer(ctx context.Context) (*http.Request, error) {
    72  	const APIVersion = "2021-06-01"
    73  	queryParameters := map[string]interface{}{
    74  		"api-version": APIVersion,
    75  	}
    76  
    77  	preparer := autorest.CreatePreparer(
    78  		autorest.AsPost(),
    79  		autorest.WithBaseURL(client.BaseURI),
    80  		autorest.WithPath("/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix"),
    81  		autorest.WithQueryParameters(queryParameters))
    82  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    83  }
    84  
    85  // ExecuteSender sends the Execute request. The method will close the
    86  // http.Response Body if it receives an error.
    87  func (client GetPrivateDNSZoneSuffixClient) ExecuteSender(req *http.Request) (*http.Response, error) {
    88  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    89  }
    90  
    91  // ExecuteResponder handles the response to the Execute request. The method always
    92  // closes the http.Response Body.
    93  func (client GetPrivateDNSZoneSuffixClient) ExecuteResponder(resp *http.Response) (result String, err error) {
    94  	err = autorest.Respond(
    95  		resp,
    96  		azure.WithErrorUnlessStatusCode(http.StatusOK),
    97  		autorest.ByUnmarshallingJSON(&result.Value),
    98  		autorest.ByClosing())
    99  	result.Response = autorest.Response{Response: resp}
   100  	return
   101  }
   102  

View as plain text