1package search 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 "github.com/gofrs/uuid" 15 "net/http" 16) 17 18// PrivateLinkResourcesClient is the client that can be used to manage Azure Cognitive Search services and API keys. 19type PrivateLinkResourcesClient struct { 20 BaseClient 21} 22 23// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. 24func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { 25 return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom 29// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 30// stack). 31func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { 32 return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// ListSupported gets a list of all supported private link resource types for the given service. 36// Parameters: 37// resourceGroupName - the name of the resource group within the current subscription. You can obtain this 38// value from the Azure Resource Manager API or the portal. 39// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource 40// group. 41// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be 42// included in response information as a way to track the request. 43func (client PrivateLinkResourcesClient) ListSupported(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result PrivateLinkResourcesResult, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListSupported") 46 defer func() { 47 sc := -1 48 if result.Response.Response != nil { 49 sc = result.Response.Response.StatusCode 50 } 51 tracing.EndSpan(ctx, sc, err) 52 }() 53 } 54 req, err := client.ListSupportedPreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", nil, "Failure preparing request") 57 return 58 } 59 60 resp, err := client.ListSupportedSender(req) 61 if err != nil { 62 result.Response = autorest.Response{Response: resp} 63 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure sending request") 64 return 65 } 66 67 result, err = client.ListSupportedResponder(resp) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure responding to request") 70 return 71 } 72 73 return 74} 75 76// ListSupportedPreparer prepares the ListSupported request. 77func (client PrivateLinkResourcesClient) ListSupportedPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "resourceGroupName": autorest.Encode("path", resourceGroupName), 80 "searchServiceName": autorest.Encode("path", searchServiceName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2020-08-01" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsGet(), 91 autorest.WithBaseURL(client.BaseURI), 92 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateLinkResources", pathParameters), 93 autorest.WithQueryParameters(queryParameters)) 94 if clientRequestID != nil { 95 preparer = autorest.DecoratePreparer(preparer, 96 autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) 97 } 98 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 99} 100 101// ListSupportedSender sends the ListSupported request. The method will close the 102// http.Response Body if it receives an error. 103func (client PrivateLinkResourcesClient) ListSupportedSender(req *http.Request) (*http.Response, error) { 104 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 105} 106 107// ListSupportedResponder handles the response to the ListSupported request. The method always 108// closes the http.Response Body. 109func (client PrivateLinkResourcesClient) ListSupportedResponder(resp *http.Response) (result PrivateLinkResourcesResult, err error) { 110 err = autorest.Respond( 111 resp, 112 azure.WithErrorUnlessStatusCode(http.StatusOK), 113 autorest.ByUnmarshallingJSON(&result), 114 autorest.ByClosing()) 115 result.Response = autorest.Response{Response: resp} 116 return 117} 118