1package containerregistry 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// ExportPipelinesClient is the client for the ExportPipelines methods of the Containerregistry service. 19type ExportPipelinesClient struct { 20 BaseClient 21} 22 23// NewExportPipelinesClient creates an instance of the ExportPipelinesClient client. 24func NewExportPipelinesClient(subscriptionID string) ExportPipelinesClient { 25 return NewExportPipelinesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewExportPipelinesClientWithBaseURI creates an instance of the ExportPipelinesClient client using a custom endpoint. 29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewExportPipelinesClientWithBaseURI(baseURI string, subscriptionID string) ExportPipelinesClient { 31 return ExportPipelinesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Create creates an export pipeline for a container registry with the specified parameters. 35// Parameters: 36// resourceGroupName - the name of the resource group to which the container registry belongs. 37// registryName - the name of the container registry. 38// exportPipelineName - the name of the export pipeline. 39// exportPipelineCreateParameters - the parameters for creating an export pipeline. 40func (client ExportPipelinesClient) Create(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline) (result ExportPipelinesCreateFuture, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/ExportPipelinesClient.Create") 43 defer func() { 44 sc := -1 45 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 46 sc = result.FutureAPI.Response().StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: resourceGroupName, 53 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 54 {TargetValue: registryName, 55 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 56 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 57 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 58 {TargetValue: exportPipelineName, 59 Constraints: []validation.Constraint{{Target: "exportPipelineName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 60 {Target: "exportPipelineName", Name: validation.MinLength, Rule: 5, Chain: nil}, 61 {Target: "exportPipelineName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 62 {TargetValue: exportPipelineCreateParameters, 63 Constraints: []validation.Constraint{{Target: "exportPipelineCreateParameters.ExportPipelineProperties", Name: validation.Null, Rule: false, 64 Chain: []validation.Constraint{{Target: "exportPipelineCreateParameters.ExportPipelineProperties.Target", Name: validation.Null, Rule: true, 65 Chain: []validation.Constraint{{Target: "exportPipelineCreateParameters.ExportPipelineProperties.Target.KeyVaultURI", Name: validation.Null, Rule: true, Chain: nil}}}, 66 }}}}}); err != nil { 67 return result, validation.NewError("containerregistry.ExportPipelinesClient", "Create", err.Error()) 68 } 69 70 req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, exportPipelineName, exportPipelineCreateParameters) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Create", nil, "Failure preparing request") 73 return 74 } 75 76 result, err = client.CreateSender(req) 77 if err != nil { 78 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Create", nil, "Failure sending request") 79 return 80 } 81 82 return 83} 84 85// CreatePreparer prepares the Create request. 86func (client ExportPipelinesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline) (*http.Request, error) { 87 pathParameters := map[string]interface{}{ 88 "exportPipelineName": autorest.Encode("path", exportPipelineName), 89 "registryName": autorest.Encode("path", registryName), 90 "resourceGroupName": autorest.Encode("path", resourceGroupName), 91 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 92 } 93 94 const APIVersion = "2019-12-01-preview" 95 queryParameters := map[string]interface{}{ 96 "api-version": APIVersion, 97 } 98 99 preparer := autorest.CreatePreparer( 100 autorest.AsContentType("application/json; charset=utf-8"), 101 autorest.AsPut(), 102 autorest.WithBaseURL(client.BaseURI), 103 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", pathParameters), 104 autorest.WithJSON(exportPipelineCreateParameters), 105 autorest.WithQueryParameters(queryParameters)) 106 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 107} 108 109// CreateSender sends the Create request. The method will close the 110// http.Response Body if it receives an error. 111func (client ExportPipelinesClient) CreateSender(req *http.Request) (future ExportPipelinesCreateFuture, err error) { 112 var resp *http.Response 113 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 114 if err != nil { 115 return 116 } 117 var azf azure.Future 118 azf, err = azure.NewFutureFromResponse(resp) 119 future.FutureAPI = &azf 120 future.Result = future.result 121 return 122} 123 124// CreateResponder handles the response to the Create request. The method always 125// closes the http.Response Body. 126func (client ExportPipelinesClient) CreateResponder(resp *http.Response) (result ExportPipeline, err error) { 127 err = autorest.Respond( 128 resp, 129 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 130 autorest.ByUnmarshallingJSON(&result), 131 autorest.ByClosing()) 132 result.Response = autorest.Response{Response: resp} 133 return 134} 135 136// Delete deletes an export pipeline from a container registry. 137// Parameters: 138// resourceGroupName - the name of the resource group to which the container registry belongs. 139// registryName - the name of the container registry. 140// exportPipelineName - the name of the export pipeline. 141func (client ExportPipelinesClient) Delete(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string) (result ExportPipelinesDeleteFuture, err error) { 142 if tracing.IsEnabled() { 143 ctx = tracing.StartSpan(ctx, fqdn+"/ExportPipelinesClient.Delete") 144 defer func() { 145 sc := -1 146 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 147 sc = result.FutureAPI.Response().StatusCode 148 } 149 tracing.EndSpan(ctx, sc, err) 150 }() 151 } 152 if err := validation.Validate([]validation.Validation{ 153 {TargetValue: resourceGroupName, 154 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 155 {TargetValue: registryName, 156 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 157 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 158 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 159 {TargetValue: exportPipelineName, 160 Constraints: []validation.Constraint{{Target: "exportPipelineName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 161 {Target: "exportPipelineName", Name: validation.MinLength, Rule: 5, Chain: nil}, 162 {Target: "exportPipelineName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 163 return result, validation.NewError("containerregistry.ExportPipelinesClient", "Delete", err.Error()) 164 } 165 166 req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, exportPipelineName) 167 if err != nil { 168 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Delete", nil, "Failure preparing request") 169 return 170 } 171 172 result, err = client.DeleteSender(req) 173 if err != nil { 174 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Delete", nil, "Failure sending request") 175 return 176 } 177 178 return 179} 180 181// DeletePreparer prepares the Delete request. 182func (client ExportPipelinesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string) (*http.Request, error) { 183 pathParameters := map[string]interface{}{ 184 "exportPipelineName": autorest.Encode("path", exportPipelineName), 185 "registryName": autorest.Encode("path", registryName), 186 "resourceGroupName": autorest.Encode("path", resourceGroupName), 187 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 188 } 189 190 const APIVersion = "2019-12-01-preview" 191 queryParameters := map[string]interface{}{ 192 "api-version": APIVersion, 193 } 194 195 preparer := autorest.CreatePreparer( 196 autorest.AsDelete(), 197 autorest.WithBaseURL(client.BaseURI), 198 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", pathParameters), 199 autorest.WithQueryParameters(queryParameters)) 200 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 201} 202 203// DeleteSender sends the Delete request. The method will close the 204// http.Response Body if it receives an error. 205func (client ExportPipelinesClient) DeleteSender(req *http.Request) (future ExportPipelinesDeleteFuture, err error) { 206 var resp *http.Response 207 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 208 if err != nil { 209 return 210 } 211 var azf azure.Future 212 azf, err = azure.NewFutureFromResponse(resp) 213 future.FutureAPI = &azf 214 future.Result = future.result 215 return 216} 217 218// DeleteResponder handles the response to the Delete request. The method always 219// closes the http.Response Body. 220func (client ExportPipelinesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 221 err = autorest.Respond( 222 resp, 223 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 224 autorest.ByClosing()) 225 result.Response = resp 226 return 227} 228 229// Get gets the properties of the export pipeline. 230// Parameters: 231// resourceGroupName - the name of the resource group to which the container registry belongs. 232// registryName - the name of the container registry. 233// exportPipelineName - the name of the export pipeline. 234func (client ExportPipelinesClient) Get(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string) (result ExportPipeline, err error) { 235 if tracing.IsEnabled() { 236 ctx = tracing.StartSpan(ctx, fqdn+"/ExportPipelinesClient.Get") 237 defer func() { 238 sc := -1 239 if result.Response.Response != nil { 240 sc = result.Response.Response.StatusCode 241 } 242 tracing.EndSpan(ctx, sc, err) 243 }() 244 } 245 if err := validation.Validate([]validation.Validation{ 246 {TargetValue: resourceGroupName, 247 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 248 {TargetValue: registryName, 249 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 250 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 251 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 252 {TargetValue: exportPipelineName, 253 Constraints: []validation.Constraint{{Target: "exportPipelineName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 254 {Target: "exportPipelineName", Name: validation.MinLength, Rule: 5, Chain: nil}, 255 {Target: "exportPipelineName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 256 return result, validation.NewError("containerregistry.ExportPipelinesClient", "Get", err.Error()) 257 } 258 259 req, err := client.GetPreparer(ctx, resourceGroupName, registryName, exportPipelineName) 260 if err != nil { 261 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Get", nil, "Failure preparing request") 262 return 263 } 264 265 resp, err := client.GetSender(req) 266 if err != nil { 267 result.Response = autorest.Response{Response: resp} 268 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Get", resp, "Failure sending request") 269 return 270 } 271 272 result, err = client.GetResponder(resp) 273 if err != nil { 274 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "Get", resp, "Failure responding to request") 275 return 276 } 277 278 return 279} 280 281// GetPreparer prepares the Get request. 282func (client ExportPipelinesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string) (*http.Request, error) { 283 pathParameters := map[string]interface{}{ 284 "exportPipelineName": autorest.Encode("path", exportPipelineName), 285 "registryName": autorest.Encode("path", registryName), 286 "resourceGroupName": autorest.Encode("path", resourceGroupName), 287 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 288 } 289 290 const APIVersion = "2019-12-01-preview" 291 queryParameters := map[string]interface{}{ 292 "api-version": APIVersion, 293 } 294 295 preparer := autorest.CreatePreparer( 296 autorest.AsGet(), 297 autorest.WithBaseURL(client.BaseURI), 298 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}", pathParameters), 299 autorest.WithQueryParameters(queryParameters)) 300 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 301} 302 303// GetSender sends the Get request. The method will close the 304// http.Response Body if it receives an error. 305func (client ExportPipelinesClient) GetSender(req *http.Request) (*http.Response, error) { 306 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 307} 308 309// GetResponder handles the response to the Get request. The method always 310// closes the http.Response Body. 311func (client ExportPipelinesClient) GetResponder(resp *http.Response) (result ExportPipeline, err error) { 312 err = autorest.Respond( 313 resp, 314 azure.WithErrorUnlessStatusCode(http.StatusOK), 315 autorest.ByUnmarshallingJSON(&result), 316 autorest.ByClosing()) 317 result.Response = autorest.Response{Response: resp} 318 return 319} 320 321// List lists all export pipelines for the specified container registry. 322// Parameters: 323// resourceGroupName - the name of the resource group to which the container registry belongs. 324// registryName - the name of the container registry. 325func (client ExportPipelinesClient) List(ctx context.Context, resourceGroupName string, registryName string) (result ExportPipelineListResultPage, err error) { 326 if tracing.IsEnabled() { 327 ctx = tracing.StartSpan(ctx, fqdn+"/ExportPipelinesClient.List") 328 defer func() { 329 sc := -1 330 if result.eplr.Response.Response != nil { 331 sc = result.eplr.Response.Response.StatusCode 332 } 333 tracing.EndSpan(ctx, sc, err) 334 }() 335 } 336 if err := validation.Validate([]validation.Validation{ 337 {TargetValue: resourceGroupName, 338 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 339 {TargetValue: registryName, 340 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 341 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 342 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 343 return result, validation.NewError("containerregistry.ExportPipelinesClient", "List", err.Error()) 344 } 345 346 result.fn = client.listNextResults 347 req, err := client.ListPreparer(ctx, resourceGroupName, registryName) 348 if err != nil { 349 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "List", nil, "Failure preparing request") 350 return 351 } 352 353 resp, err := client.ListSender(req) 354 if err != nil { 355 result.eplr.Response = autorest.Response{Response: resp} 356 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "List", resp, "Failure sending request") 357 return 358 } 359 360 result.eplr, err = client.ListResponder(resp) 361 if err != nil { 362 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "List", resp, "Failure responding to request") 363 return 364 } 365 if result.eplr.hasNextLink() && result.eplr.IsEmpty() { 366 err = result.NextWithContext(ctx) 367 return 368 } 369 370 return 371} 372 373// ListPreparer prepares the List request. 374func (client ExportPipelinesClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 375 pathParameters := map[string]interface{}{ 376 "registryName": autorest.Encode("path", registryName), 377 "resourceGroupName": autorest.Encode("path", resourceGroupName), 378 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 379 } 380 381 const APIVersion = "2019-12-01-preview" 382 queryParameters := map[string]interface{}{ 383 "api-version": APIVersion, 384 } 385 386 preparer := autorest.CreatePreparer( 387 autorest.AsGet(), 388 autorest.WithBaseURL(client.BaseURI), 389 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines", pathParameters), 390 autorest.WithQueryParameters(queryParameters)) 391 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 392} 393 394// ListSender sends the List request. The method will close the 395// http.Response Body if it receives an error. 396func (client ExportPipelinesClient) ListSender(req *http.Request) (*http.Response, error) { 397 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 398} 399 400// ListResponder handles the response to the List request. The method always 401// closes the http.Response Body. 402func (client ExportPipelinesClient) ListResponder(resp *http.Response) (result ExportPipelineListResult, err error) { 403 err = autorest.Respond( 404 resp, 405 azure.WithErrorUnlessStatusCode(http.StatusOK), 406 autorest.ByUnmarshallingJSON(&result), 407 autorest.ByClosing()) 408 result.Response = autorest.Response{Response: resp} 409 return 410} 411 412// listNextResults retrieves the next set of results, if any. 413func (client ExportPipelinesClient) listNextResults(ctx context.Context, lastResults ExportPipelineListResult) (result ExportPipelineListResult, err error) { 414 req, err := lastResults.exportPipelineListResultPreparer(ctx) 415 if err != nil { 416 return result, autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "listNextResults", nil, "Failure preparing next results request") 417 } 418 if req == nil { 419 return 420 } 421 resp, err := client.ListSender(req) 422 if err != nil { 423 result.Response = autorest.Response{Response: resp} 424 return result, autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "listNextResults", resp, "Failure sending next results request") 425 } 426 result, err = client.ListResponder(resp) 427 if err != nil { 428 err = autorest.NewErrorWithError(err, "containerregistry.ExportPipelinesClient", "listNextResults", resp, "Failure responding to next results request") 429 } 430 return 431} 432 433// ListComplete enumerates all values, automatically crossing page boundaries as required. 434func (client ExportPipelinesClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result ExportPipelineListResultIterator, err error) { 435 if tracing.IsEnabled() { 436 ctx = tracing.StartSpan(ctx, fqdn+"/ExportPipelinesClient.List") 437 defer func() { 438 sc := -1 439 if result.Response().Response.Response != nil { 440 sc = result.page.Response().Response.Response.StatusCode 441 } 442 tracing.EndSpan(ctx, sc, err) 443 }() 444 } 445 result.page, err = client.List(ctx, resourceGroupName, registryName) 446 return 447} 448