1package datafactory 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// PrivateEndpointConnectionClient is the the Azure Data Factory V2 management API provides a RESTful set of web 19// services that interact with Azure Data Factory V2 services. 20type PrivateEndpointConnectionClient struct { 21 BaseClient 22} 23 24// NewPrivateEndpointConnectionClient creates an instance of the PrivateEndpointConnectionClient client. 25func NewPrivateEndpointConnectionClient(subscriptionID string) PrivateEndpointConnectionClient { 26 return NewPrivateEndpointConnectionClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewPrivateEndpointConnectionClientWithBaseURI creates an instance of the PrivateEndpointConnectionClient client 30// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 31// clouds, Azure stack). 32func NewPrivateEndpointConnectionClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionClient { 33 return PrivateEndpointConnectionClient{NewWithBaseURI(baseURI, subscriptionID)} 34} 35 36// CreateOrUpdate approves or rejects a private endpoint connection 37// Parameters: 38// resourceGroupName - the resource group name. 39// factoryName - the factory name. 40// privateEndpointConnectionName - the private endpoint connection name. 41// ifMatch - eTag of the private endpoint connection entity. Should only be specified for update, for which it 42// should match existing entity or can be * for unconditional update. 43func (client PrivateEndpointConnectionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string, privateEndpointWrapper PrivateLinkConnectionApprovalRequestResource, ifMatch string) (result PrivateEndpointConnectionResource, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.CreateOrUpdate") 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 if err := validation.Validate([]validation.Validation{ 55 {TargetValue: resourceGroupName, 56 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 57 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 58 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 59 {TargetValue: factoryName, 60 Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 61 {Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil}, 62 {Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil { 63 return result, validation.NewError("datafactory.PrivateEndpointConnectionClient", "CreateOrUpdate", err.Error()) 64 } 65 66 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, factoryName, privateEndpointConnectionName, privateEndpointWrapper, ifMatch) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.CreateOrUpdateSender(req) 73 if err != nil { 74 result.Response = autorest.Response{Response: resp} 75 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "CreateOrUpdate", resp, "Failure sending request") 76 return 77 } 78 79 result, err = client.CreateOrUpdateResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "CreateOrUpdate", resp, "Failure responding to request") 82 return 83 } 84 85 return 86} 87 88// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 89func (client PrivateEndpointConnectionClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string, privateEndpointWrapper PrivateLinkConnectionApprovalRequestResource, ifMatch string) (*http.Request, error) { 90 pathParameters := map[string]interface{}{ 91 "factoryName": autorest.Encode("path", factoryName), 92 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 93 "resourceGroupName": autorest.Encode("path", resourceGroupName), 94 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 95 } 96 97 const APIVersion = "2018-06-01" 98 queryParameters := map[string]interface{}{ 99 "api-version": APIVersion, 100 } 101 102 preparer := autorest.CreatePreparer( 103 autorest.AsContentType("application/json; charset=utf-8"), 104 autorest.AsPut(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 107 autorest.WithJSON(privateEndpointWrapper), 108 autorest.WithQueryParameters(queryParameters)) 109 if len(ifMatch) > 0 { 110 preparer = autorest.DecoratePreparer(preparer, 111 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 112 } 113 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 114} 115 116// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 117// http.Response Body if it receives an error. 118func (client PrivateEndpointConnectionClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 119 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 120} 121 122// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 123// closes the http.Response Body. 124func (client PrivateEndpointConnectionClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnectionResource, err error) { 125 err = autorest.Respond( 126 resp, 127 azure.WithErrorUnlessStatusCode(http.StatusOK), 128 autorest.ByUnmarshallingJSON(&result), 129 autorest.ByClosing()) 130 result.Response = autorest.Response{Response: resp} 131 return 132} 133 134// Delete deletes a private endpoint connection 135// Parameters: 136// resourceGroupName - the resource group name. 137// factoryName - the factory name. 138// privateEndpointConnectionName - the private endpoint connection name. 139func (client PrivateEndpointConnectionClient) Delete(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string) (result autorest.Response, err error) { 140 if tracing.IsEnabled() { 141 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.Delete") 142 defer func() { 143 sc := -1 144 if result.Response != nil { 145 sc = result.Response.StatusCode 146 } 147 tracing.EndSpan(ctx, sc, err) 148 }() 149 } 150 if err := validation.Validate([]validation.Validation{ 151 {TargetValue: resourceGroupName, 152 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 153 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 154 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 155 {TargetValue: factoryName, 156 Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 157 {Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil}, 158 {Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil { 159 return result, validation.NewError("datafactory.PrivateEndpointConnectionClient", "Delete", err.Error()) 160 } 161 162 req, err := client.DeletePreparer(ctx, resourceGroupName, factoryName, privateEndpointConnectionName) 163 if err != nil { 164 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request") 165 return 166 } 167 168 resp, err := client.DeleteSender(req) 169 if err != nil { 170 result.Response = resp 171 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Delete", resp, "Failure sending request") 172 return 173 } 174 175 result, err = client.DeleteResponder(resp) 176 if err != nil { 177 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Delete", resp, "Failure responding to request") 178 return 179 } 180 181 return 182} 183 184// DeletePreparer prepares the Delete request. 185func (client PrivateEndpointConnectionClient) DeletePreparer(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string) (*http.Request, error) { 186 pathParameters := map[string]interface{}{ 187 "factoryName": autorest.Encode("path", factoryName), 188 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 189 "resourceGroupName": autorest.Encode("path", resourceGroupName), 190 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 191 } 192 193 const APIVersion = "2018-06-01" 194 queryParameters := map[string]interface{}{ 195 "api-version": APIVersion, 196 } 197 198 preparer := autorest.CreatePreparer( 199 autorest.AsDelete(), 200 autorest.WithBaseURL(client.BaseURI), 201 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 202 autorest.WithQueryParameters(queryParameters)) 203 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 204} 205 206// DeleteSender sends the Delete request. The method will close the 207// http.Response Body if it receives an error. 208func (client PrivateEndpointConnectionClient) DeleteSender(req *http.Request) (*http.Response, error) { 209 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 210} 211 212// DeleteResponder handles the response to the Delete request. The method always 213// closes the http.Response Body. 214func (client PrivateEndpointConnectionClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 215 err = autorest.Respond( 216 resp, 217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 218 autorest.ByClosing()) 219 result.Response = resp 220 return 221} 222 223// Get gets a private endpoint connection 224// Parameters: 225// resourceGroupName - the resource group name. 226// factoryName - the factory name. 227// privateEndpointConnectionName - the private endpoint connection name. 228// ifNoneMatch - eTag of the private endpoint connection entity. Should only be specified for get. If the ETag 229// matches the existing entity tag, or if * was provided, then no content will be returned. 230func (client PrivateEndpointConnectionClient) Get(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string, ifNoneMatch string) (result PrivateEndpointConnectionResource, err error) { 231 if tracing.IsEnabled() { 232 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionClient.Get") 233 defer func() { 234 sc := -1 235 if result.Response.Response != nil { 236 sc = result.Response.Response.StatusCode 237 } 238 tracing.EndSpan(ctx, sc, err) 239 }() 240 } 241 if err := validation.Validate([]validation.Validation{ 242 {TargetValue: resourceGroupName, 243 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 244 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 245 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 246 {TargetValue: factoryName, 247 Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil}, 248 {Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil}, 249 {Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil { 250 return result, validation.NewError("datafactory.PrivateEndpointConnectionClient", "Get", err.Error()) 251 } 252 253 req, err := client.GetPreparer(ctx, resourceGroupName, factoryName, privateEndpointConnectionName, ifNoneMatch) 254 if err != nil { 255 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request") 256 return 257 } 258 259 resp, err := client.GetSender(req) 260 if err != nil { 261 result.Response = autorest.Response{Response: resp} 262 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Get", resp, "Failure sending request") 263 return 264 } 265 266 result, err = client.GetResponder(resp) 267 if err != nil { 268 err = autorest.NewErrorWithError(err, "datafactory.PrivateEndpointConnectionClient", "Get", resp, "Failure responding to request") 269 return 270 } 271 272 return 273} 274 275// GetPreparer prepares the Get request. 276func (client PrivateEndpointConnectionClient) GetPreparer(ctx context.Context, resourceGroupName string, factoryName string, privateEndpointConnectionName string, ifNoneMatch string) (*http.Request, error) { 277 pathParameters := map[string]interface{}{ 278 "factoryName": autorest.Encode("path", factoryName), 279 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 280 "resourceGroupName": autorest.Encode("path", resourceGroupName), 281 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 282 } 283 284 const APIVersion = "2018-06-01" 285 queryParameters := map[string]interface{}{ 286 "api-version": APIVersion, 287 } 288 289 preparer := autorest.CreatePreparer( 290 autorest.AsGet(), 291 autorest.WithBaseURL(client.BaseURI), 292 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 293 autorest.WithQueryParameters(queryParameters)) 294 if len(ifNoneMatch) > 0 { 295 preparer = autorest.DecoratePreparer(preparer, 296 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 297 } 298 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 299} 300 301// GetSender sends the Get request. The method will close the 302// http.Response Body if it receives an error. 303func (client PrivateEndpointConnectionClient) GetSender(req *http.Request) (*http.Response, error) { 304 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 305} 306 307// GetResponder handles the response to the Get request. The method always 308// closes the http.Response Body. 309func (client PrivateEndpointConnectionClient) GetResponder(resp *http.Response) (result PrivateEndpointConnectionResource, err error) { 310 err = autorest.Respond( 311 resp, 312 azure.WithErrorUnlessStatusCode(http.StatusOK), 313 autorest.ByUnmarshallingJSON(&result), 314 autorest.ByClosing()) 315 result.Response = autorest.Response{Response: resp} 316 return 317} 318