1package search 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/tracing" 25 "github.com/gofrs/uuid" 26 "net/http" 27) 28 29// PrivateLinkResourcesClient is the client that can be used to manage Azure Cognitive Search services and API keys. 30type PrivateLinkResourcesClient struct { 31 BaseClient 32} 33 34// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. 35func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { 36 return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom 40// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 41// stack). 42func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { 43 return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// ListSupported gets a list of all supported private link resource types for the given service. 47// Parameters: 48// resourceGroupName - the name of the resource group within the current subscription. You can obtain this 49// value from the Azure Resource Manager API or the portal. 50// searchServiceName - the name of the Azure Cognitive Search service associated with the specified resource 51// group. 52// clientRequestID - a client-generated GUID value that identifies this request. If specified, this will be 53// included in response information as a way to track the request. 54func (client PrivateLinkResourcesClient) ListSupported(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (result PrivateLinkResourcesResult, err error) { 55 if tracing.IsEnabled() { 56 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListSupported") 57 defer func() { 58 sc := -1 59 if result.Response.Response != nil { 60 sc = result.Response.Response.StatusCode 61 } 62 tracing.EndSpan(ctx, sc, err) 63 }() 64 } 65 req, err := client.ListSupportedPreparer(ctx, resourceGroupName, searchServiceName, clientRequestID) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", nil, "Failure preparing request") 68 return 69 } 70 71 resp, err := client.ListSupportedSender(req) 72 if err != nil { 73 result.Response = autorest.Response{Response: resp} 74 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure sending request") 75 return 76 } 77 78 result, err = client.ListSupportedResponder(resp) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "search.PrivateLinkResourcesClient", "ListSupported", resp, "Failure responding to request") 81 return 82 } 83 84 return 85} 86 87// ListSupportedPreparer prepares the ListSupported request. 88func (client PrivateLinkResourcesClient) ListSupportedPreparer(ctx context.Context, resourceGroupName string, searchServiceName string, clientRequestID *uuid.UUID) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "resourceGroupName": autorest.Encode("path", resourceGroupName), 91 "searchServiceName": autorest.Encode("path", searchServiceName), 92 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 93 } 94 95 const APIVersion = "2020-03-13" 96 queryParameters := map[string]interface{}{ 97 "api-version": APIVersion, 98 } 99 100 preparer := autorest.CreatePreparer( 101 autorest.AsGet(), 102 autorest.WithBaseURL(client.BaseURI), 103 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/privateLinkResources", pathParameters), 104 autorest.WithQueryParameters(queryParameters)) 105 if clientRequestID != nil { 106 preparer = autorest.DecoratePreparer(preparer, 107 autorest.WithHeader("x-ms-client-request-id", autorest.String(clientRequestID))) 108 } 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// ListSupportedSender sends the ListSupported request. The method will close the 113// http.Response Body if it receives an error. 114func (client PrivateLinkResourcesClient) ListSupportedSender(req *http.Request) (*http.Response, error) { 115 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 116} 117 118// ListSupportedResponder handles the response to the ListSupported request. The method always 119// closes the http.Response Body. 120func (client PrivateLinkResourcesClient) ListSupportedResponder(resp *http.Response) (result PrivateLinkResourcesResult, err error) { 121 err = autorest.Respond( 122 resp, 123 azure.WithErrorUnlessStatusCode(http.StatusOK), 124 autorest.ByUnmarshallingJSON(&result), 125 autorest.ByClosing()) 126 result.Response = autorest.Response{Response: resp} 127 return 128} 129