1package storage 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// PrivateEndpointConnectionsClient is the the Azure Storage Management API. 19type PrivateEndpointConnectionsClient struct { 20 BaseClient 21} 22 23// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. 24func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { 25 return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client 29// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 30// clouds, Azure stack). 31func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { 32 return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// Delete deletes the specified private endpoint connection associated with the storage account. 36// Parameters: 37// resourceGroupName - the name of the resource group within the user's subscription. The name is case 38// insensitive. 39// accountName - the name of the storage account within the specified resource group. Storage account names 40// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 41// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure 42// resource 43func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result autorest.Response, err error) { 44 if tracing.IsEnabled() { 45 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") 46 defer func() { 47 sc := -1 48 if result.Response != nil { 49 sc = result.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: accountName, 60 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 61 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 62 {TargetValue: client.SubscriptionID, 63 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 64 return result, validation.NewError("storage.PrivateEndpointConnectionsClient", "Delete", err.Error()) 65 } 66 67 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") 70 return 71 } 72 73 resp, err := client.DeleteSender(req) 74 if err != nil { 75 result.Response = resp 76 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Delete", resp, "Failure sending request") 77 return 78 } 79 80 result, err = client.DeleteResponder(resp) 81 if err != nil { 82 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Delete", resp, "Failure responding to request") 83 return 84 } 85 86 return 87} 88 89// DeletePreparer prepares the Delete request. 90func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { 91 pathParameters := map[string]interface{}{ 92 "accountName": autorest.Encode("path", accountName), 93 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 } 97 98 const APIVersion = "2019-06-01" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 103 preparer := autorest.CreatePreparer( 104 autorest.AsDelete(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 107 autorest.WithQueryParameters(queryParameters)) 108 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 109} 110 111// DeleteSender sends the Delete request. The method will close the 112// http.Response Body if it receives an error. 113func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (*http.Response, error) { 114 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 115} 116 117// DeleteResponder handles the response to the Delete request. The method always 118// closes the http.Response Body. 119func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 120 err = autorest.Respond( 121 resp, 122 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 123 autorest.ByClosing()) 124 result.Response = resp 125 return 126} 127 128// Get gets the specified private endpoint connection associated with the storage account. 129// Parameters: 130// resourceGroupName - the name of the resource group within the user's subscription. The name is case 131// insensitive. 132// accountName - the name of the storage account within the specified resource group. Storage account names 133// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 134// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure 135// resource 136func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { 137 if tracing.IsEnabled() { 138 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") 139 defer func() { 140 sc := -1 141 if result.Response.Response != nil { 142 sc = result.Response.Response.StatusCode 143 } 144 tracing.EndSpan(ctx, sc, err) 145 }() 146 } 147 if err := validation.Validate([]validation.Validation{ 148 {TargetValue: resourceGroupName, 149 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 150 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 151 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 152 {TargetValue: accountName, 153 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 154 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 155 {TargetValue: client.SubscriptionID, 156 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 157 return result, validation.NewError("storage.PrivateEndpointConnectionsClient", "Get", err.Error()) 158 } 159 160 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName) 161 if err != nil { 162 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") 163 return 164 } 165 166 resp, err := client.GetSender(req) 167 if err != nil { 168 result.Response = autorest.Response{Response: resp} 169 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") 170 return 171 } 172 173 result, err = client.GetResponder(resp) 174 if err != nil { 175 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") 176 return 177 } 178 179 return 180} 181 182// GetPreparer prepares the Get request. 183func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string) (*http.Request, error) { 184 pathParameters := map[string]interface{}{ 185 "accountName": autorest.Encode("path", accountName), 186 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 187 "resourceGroupName": autorest.Encode("path", resourceGroupName), 188 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 189 } 190 191 const APIVersion = "2019-06-01" 192 queryParameters := map[string]interface{}{ 193 "api-version": APIVersion, 194 } 195 196 preparer := autorest.CreatePreparer( 197 autorest.AsGet(), 198 autorest.WithBaseURL(client.BaseURI), 199 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 200 autorest.WithQueryParameters(queryParameters)) 201 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 202} 203 204// GetSender sends the Get request. The method will close the 205// http.Response Body if it receives an error. 206func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { 207 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 208} 209 210// GetResponder handles the response to the Get request. The method always 211// closes the http.Response Body. 212func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { 213 err = autorest.Respond( 214 resp, 215 azure.WithErrorUnlessStatusCode(http.StatusOK), 216 autorest.ByUnmarshallingJSON(&result), 217 autorest.ByClosing()) 218 result.Response = autorest.Response{Response: resp} 219 return 220} 221 222// List list all the private endpoint connections associated with the storage account. 223// Parameters: 224// resourceGroupName - the name of the resource group within the user's subscription. The name is case 225// insensitive. 226// accountName - the name of the storage account within the specified resource group. Storage account names 227// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 228func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string) (result PrivateEndpointConnectionListResult, err error) { 229 if tracing.IsEnabled() { 230 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") 231 defer func() { 232 sc := -1 233 if result.Response.Response != nil { 234 sc = result.Response.Response.StatusCode 235 } 236 tracing.EndSpan(ctx, sc, err) 237 }() 238 } 239 if err := validation.Validate([]validation.Validation{ 240 {TargetValue: resourceGroupName, 241 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 242 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 243 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 244 {TargetValue: accountName, 245 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 246 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 247 {TargetValue: client.SubscriptionID, 248 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 249 return result, validation.NewError("storage.PrivateEndpointConnectionsClient", "List", err.Error()) 250 } 251 252 req, err := client.ListPreparer(ctx, resourceGroupName, accountName) 253 if err != nil { 254 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") 255 return 256 } 257 258 resp, err := client.ListSender(req) 259 if err != nil { 260 result.Response = autorest.Response{Response: resp} 261 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") 262 return 263 } 264 265 result, err = client.ListResponder(resp) 266 if err != nil { 267 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") 268 return 269 } 270 271 return 272} 273 274// ListPreparer prepares the List request. 275func (client PrivateEndpointConnectionsClient) ListPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 276 pathParameters := map[string]interface{}{ 277 "accountName": autorest.Encode("path", accountName), 278 "resourceGroupName": autorest.Encode("path", resourceGroupName), 279 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 280 } 281 282 const APIVersion = "2019-06-01" 283 queryParameters := map[string]interface{}{ 284 "api-version": APIVersion, 285 } 286 287 preparer := autorest.CreatePreparer( 288 autorest.AsGet(), 289 autorest.WithBaseURL(client.BaseURI), 290 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", pathParameters), 291 autorest.WithQueryParameters(queryParameters)) 292 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 293} 294 295// ListSender sends the List request. The method will close the 296// http.Response Body if it receives an error. 297func (client PrivateEndpointConnectionsClient) ListSender(req *http.Request) (*http.Response, error) { 298 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 299} 300 301// ListResponder handles the response to the List request. The method always 302// closes the http.Response Body. 303func (client PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionListResult, err error) { 304 err = autorest.Respond( 305 resp, 306 azure.WithErrorUnlessStatusCode(http.StatusOK), 307 autorest.ByUnmarshallingJSON(&result), 308 autorest.ByClosing()) 309 result.Response = autorest.Response{Response: resp} 310 return 311} 312 313// Put update the state of specified private endpoint connection associated with the storage account. 314// Parameters: 315// resourceGroupName - the name of the resource group within the user's subscription. The name is case 316// insensitive. 317// accountName - the name of the storage account within the specified resource group. Storage account names 318// must be between 3 and 24 characters in length and use numbers and lower-case letters only. 319// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure 320// resource 321// properties - the private endpoint connection properties. 322func (client PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnection, err error) { 323 if tracing.IsEnabled() { 324 ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Put") 325 defer func() { 326 sc := -1 327 if result.Response.Response != nil { 328 sc = result.Response.Response.StatusCode 329 } 330 tracing.EndSpan(ctx, sc, err) 331 }() 332 } 333 if err := validation.Validate([]validation.Validation{ 334 {TargetValue: resourceGroupName, 335 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 336 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 337 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 338 {TargetValue: accountName, 339 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, 340 {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, 341 {TargetValue: client.SubscriptionID, 342 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 343 {TargetValue: properties, 344 Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, 345 Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 346 return result, validation.NewError("storage.PrivateEndpointConnectionsClient", "Put", err.Error()) 347 } 348 349 req, err := client.PutPreparer(ctx, resourceGroupName, accountName, privateEndpointConnectionName, properties) 350 if err != nil { 351 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Put", nil, "Failure preparing request") 352 return 353 } 354 355 resp, err := client.PutSender(req) 356 if err != nil { 357 result.Response = autorest.Response{Response: resp} 358 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Put", resp, "Failure sending request") 359 return 360 } 361 362 result, err = client.PutResponder(resp) 363 if err != nil { 364 err = autorest.NewErrorWithError(err, "storage.PrivateEndpointConnectionsClient", "Put", resp, "Failure responding to request") 365 return 366 } 367 368 return 369} 370 371// PutPreparer prepares the Put request. 372func (client PrivateEndpointConnectionsClient) PutPreparer(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { 373 pathParameters := map[string]interface{}{ 374 "accountName": autorest.Encode("path", accountName), 375 "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), 376 "resourceGroupName": autorest.Encode("path", resourceGroupName), 377 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 378 } 379 380 const APIVersion = "2019-06-01" 381 queryParameters := map[string]interface{}{ 382 "api-version": APIVersion, 383 } 384 385 preparer := autorest.CreatePreparer( 386 autorest.AsContentType("application/json; charset=utf-8"), 387 autorest.AsPut(), 388 autorest.WithBaseURL(client.BaseURI), 389 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), 390 autorest.WithJSON(properties), 391 autorest.WithQueryParameters(queryParameters)) 392 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 393} 394 395// PutSender sends the Put request. The method will close the 396// http.Response Body if it receives an error. 397func (client PrivateEndpointConnectionsClient) PutSender(req *http.Request) (*http.Response, error) { 398 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 399} 400 401// PutResponder handles the response to the Put request. The method always 402// closes the http.Response Body. 403func (client PrivateEndpointConnectionsClient) PutResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { 404 err = autorest.Respond( 405 resp, 406 azure.WithErrorUnlessStatusCode(http.StatusOK), 407 autorest.ByUnmarshallingJSON(&result), 408 autorest.ByClosing()) 409 result.Response = autorest.Response{Response: resp} 410 return 411} 412