1package synapse 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/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// PrivateEndpointConnectionsPrivateLinkHubClient is the azure Synapse Analytics Management Client 19type PrivateEndpointConnectionsPrivateLinkHubClient struct { 20 BaseClient 21} 22 23// NewPrivateEndpointConnectionsPrivateLinkHubClient creates an instance of the 24// PrivateEndpointConnectionsPrivateLinkHubClient client. 25func NewPrivateEndpointConnectionsPrivateLinkHubClient(subscriptionID string) PrivateEndpointConnectionsPrivateLinkHubClient { 26 return NewPrivateEndpointConnectionsPrivateLinkHubClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewPrivateEndpointConnectionsPrivateLinkHubClientWithBaseURI creates an instance of the 30// PrivateEndpointConnectionsPrivateLinkHubClient client using a custom endpoint. Use this when interacting with an 31// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 32func NewPrivateEndpointConnectionsPrivateLinkHubClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsPrivateLinkHubClient { 33 return PrivateEndpointConnectionsPrivateLinkHubClient{NewWithBaseURI(baseURI, subscriptionID)} 34} 35 36// List get all PrivateEndpointConnections in the PrivateLinkHub 37// Parameters: 38// resourceGroupName - the name of the resource group. The name is case insensitive. 39// privateLinkHubName - name of the privateLinkHub 40func (client PrivateEndpointConnectionsPrivateLinkHubClient) List(ctx context.Context, resourceGroupName string, privateLinkHubName string) (result PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponsePage, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsPrivateLinkHubClient.List") 43 defer func() { 44 sc := -1 45 if result.pecfplhrcr.Response.Response != nil { 46 sc = result.pecfplhrcr.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: client.SubscriptionID, 53 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 54 {TargetValue: resourceGroupName, 55 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 56 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 57 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 58 return result, validation.NewError("synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "List", err.Error()) 59 } 60 61 result.fn = client.listNextResults 62 req, err := client.ListPreparer(ctx, resourceGroupName, privateLinkHubName) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "List", nil, "Failure preparing request") 65 return 66 } 67 68 resp, err := client.ListSender(req) 69 if err != nil { 70 result.pecfplhrcr.Response = autorest.Response{Response: resp} 71 err = autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "List", resp, "Failure sending request") 72 return 73 } 74 75 result.pecfplhrcr, err = client.ListResponder(resp) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "List", resp, "Failure responding to request") 78 return 79 } 80 if result.pecfplhrcr.hasNextLink() && result.pecfplhrcr.IsEmpty() { 81 err = result.NextWithContext(ctx) 82 return 83 } 84 85 return 86} 87 88// ListPreparer prepares the List request. 89func (client PrivateEndpointConnectionsPrivateLinkHubClient) ListPreparer(ctx context.Context, resourceGroupName string, privateLinkHubName string) (*http.Request, error) { 90 pathParameters := map[string]interface{}{ 91 "privateLinkHubName": autorest.Encode("path", privateLinkHubName), 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 } 95 96 const APIVersion = "2020-12-01" 97 queryParameters := map[string]interface{}{ 98 "api-version": APIVersion, 99 } 100 101 preparer := autorest.CreatePreparer( 102 autorest.AsGet(), 103 autorest.WithBaseURL(client.BaseURI), 104 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections", pathParameters), 105 autorest.WithQueryParameters(queryParameters)) 106 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 107} 108 109// ListSender sends the List request. The method will close the 110// http.Response Body if it receives an error. 111func (client PrivateEndpointConnectionsPrivateLinkHubClient) ListSender(req *http.Request) (*http.Response, error) { 112 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 113} 114 115// ListResponder handles the response to the List request. The method always 116// closes the http.Response Body. 117func (client PrivateEndpointConnectionsPrivateLinkHubClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse, err error) { 118 err = autorest.Respond( 119 resp, 120 azure.WithErrorUnlessStatusCode(http.StatusOK), 121 autorest.ByUnmarshallingJSON(&result), 122 autorest.ByClosing()) 123 result.Response = autorest.Response{Response: resp} 124 return 125} 126 127// listNextResults retrieves the next set of results, if any. 128func (client PrivateEndpointConnectionsPrivateLinkHubClient) listNextResults(ctx context.Context, lastResults PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse) (result PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse, err error) { 129 req, err := lastResults.privateEndpointConnectionForPrivateLinkHubResourceCollectionResponsePreparer(ctx) 130 if err != nil { 131 return result, autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "listNextResults", nil, "Failure preparing next results request") 132 } 133 if req == nil { 134 return 135 } 136 resp, err := client.ListSender(req) 137 if err != nil { 138 result.Response = autorest.Response{Response: resp} 139 return result, autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "listNextResults", resp, "Failure sending next results request") 140 } 141 result, err = client.ListResponder(resp) 142 if err != nil { 143 err = autorest.NewErrorWithError(err, "synapse.PrivateEndpointConnectionsPrivateLinkHubClient", "listNextResults", resp, "Failure responding to next results request") 144 } 145 return 146} 147 148// ListComplete enumerates all values, automatically crossing page boundaries as required. 149func (client PrivateEndpointConnectionsPrivateLinkHubClient) ListComplete(ctx context.Context, resourceGroupName string, privateLinkHubName string) (result PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponseIterator, err error) { 150 if tracing.IsEnabled() { 151 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsPrivateLinkHubClient.List") 152 defer func() { 153 sc := -1 154 if result.Response().Response.Response != nil { 155 sc = result.page.Response().Response.Response.StatusCode 156 } 157 tracing.EndSpan(ctx, sc, err) 158 }() 159 } 160 result.page, err = client.List(ctx, resourceGroupName, privateLinkHubName) 161 return 162} 163