1package apimanagement 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/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// APIReleaseClient is the apiManagement Client 30type APIReleaseClient struct { 31 BaseClient 32} 33 34// NewAPIReleaseClient creates an instance of the APIReleaseClient client. 35func NewAPIReleaseClient(subscriptionID string) APIReleaseClient { 36 return NewAPIReleaseClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewAPIReleaseClientWithBaseURI creates an instance of the APIReleaseClient client. 40func NewAPIReleaseClientWithBaseURI(baseURI string, subscriptionID string) APIReleaseClient { 41 return APIReleaseClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CreateOrUpdate creates a new Release for the API. 45// Parameters: 46// resourceGroupName - the name of the resource group. 47// serviceName - the name of the API Management service. 48// apiid - API identifier. Must be unique in the current API Management service instance. 49// releaseID - release identifier within an API. Must be unique in the current API Management service instance. 50// parameters - create parameters. 51// ifMatch - eTag of the Entity. Not required when creating an entity, but required when updating an entity. 52func (client APIReleaseClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (result APIReleaseContract, err error) { 53 if tracing.IsEnabled() { 54 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.CreateOrUpdate") 55 defer func() { 56 sc := -1 57 if result.Response.Response != nil { 58 sc = result.Response.Response.StatusCode 59 } 60 tracing.EndSpan(ctx, sc, err) 61 }() 62 } 63 if err := validation.Validate([]validation.Validation{ 64 {TargetValue: serviceName, 65 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 66 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 67 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 68 {TargetValue: apiid, 69 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 70 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 71 {TargetValue: releaseID, 72 Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 73 {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, 74 {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 75 return result, validation.NewError("apimanagement.APIReleaseClient", "CreateOrUpdate", err.Error()) 76 } 77 78 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, parameters, ifMatch) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", nil, "Failure preparing request") 81 return 82 } 83 84 resp, err := client.CreateOrUpdateSender(req) 85 if err != nil { 86 result.Response = autorest.Response{Response: resp} 87 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", resp, "Failure sending request") 88 return 89 } 90 91 result, err = client.CreateOrUpdateResponder(resp) 92 if err != nil { 93 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "CreateOrUpdate", resp, "Failure responding to request") 94 } 95 96 return 97} 98 99// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 100func (client APIReleaseClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (*http.Request, error) { 101 pathParameters := map[string]interface{}{ 102 "apiId": autorest.Encode("path", apiid), 103 "releaseId": autorest.Encode("path", releaseID), 104 "resourceGroupName": autorest.Encode("path", resourceGroupName), 105 "serviceName": autorest.Encode("path", serviceName), 106 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 107 } 108 109 const APIVersion = "2019-01-01" 110 queryParameters := map[string]interface{}{ 111 "api-version": APIVersion, 112 } 113 114 preparer := autorest.CreatePreparer( 115 autorest.AsContentType("application/json; charset=utf-8"), 116 autorest.AsPut(), 117 autorest.WithBaseURL(client.BaseURI), 118 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), 119 autorest.WithJSON(parameters), 120 autorest.WithQueryParameters(queryParameters)) 121 if len(ifMatch) > 0 { 122 preparer = autorest.DecoratePreparer(preparer, 123 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 124 } 125 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 126} 127 128// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 129// http.Response Body if it receives an error. 130func (client APIReleaseClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 131 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 132 return autorest.SendWithSender(client, req, sd...) 133} 134 135// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 136// closes the http.Response Body. 137func (client APIReleaseClient) CreateOrUpdateResponder(resp *http.Response) (result APIReleaseContract, err error) { 138 err = autorest.Respond( 139 resp, 140 client.ByInspecting(), 141 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 142 autorest.ByUnmarshallingJSON(&result), 143 autorest.ByClosing()) 144 result.Response = autorest.Response{Response: resp} 145 return 146} 147 148// Delete deletes the specified release in the API. 149// Parameters: 150// resourceGroupName - the name of the resource group. 151// serviceName - the name of the API Management service. 152// apiid - API identifier. Must be unique in the current API Management service instance. 153// releaseID - release identifier within an API. Must be unique in the current API Management service instance. 154// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 155// request or it should be * for unconditional update. 156func (client APIReleaseClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, ifMatch string) (result autorest.Response, err error) { 157 if tracing.IsEnabled() { 158 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Delete") 159 defer func() { 160 sc := -1 161 if result.Response != nil { 162 sc = result.Response.StatusCode 163 } 164 tracing.EndSpan(ctx, sc, err) 165 }() 166 } 167 if err := validation.Validate([]validation.Validation{ 168 {TargetValue: serviceName, 169 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 170 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 171 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 172 {TargetValue: apiid, 173 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 174 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 175 {TargetValue: releaseID, 176 Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 177 {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, 178 {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 179 return result, validation.NewError("apimanagement.APIReleaseClient", "Delete", err.Error()) 180 } 181 182 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, ifMatch) 183 if err != nil { 184 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", nil, "Failure preparing request") 185 return 186 } 187 188 resp, err := client.DeleteSender(req) 189 if err != nil { 190 result.Response = resp 191 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", resp, "Failure sending request") 192 return 193 } 194 195 result, err = client.DeleteResponder(resp) 196 if err != nil { 197 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Delete", resp, "Failure responding to request") 198 } 199 200 return 201} 202 203// DeletePreparer prepares the Delete request. 204func (client APIReleaseClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, ifMatch string) (*http.Request, error) { 205 pathParameters := map[string]interface{}{ 206 "apiId": autorest.Encode("path", apiid), 207 "releaseId": autorest.Encode("path", releaseID), 208 "resourceGroupName": autorest.Encode("path", resourceGroupName), 209 "serviceName": autorest.Encode("path", serviceName), 210 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 211 } 212 213 const APIVersion = "2019-01-01" 214 queryParameters := map[string]interface{}{ 215 "api-version": APIVersion, 216 } 217 218 preparer := autorest.CreatePreparer( 219 autorest.AsDelete(), 220 autorest.WithBaseURL(client.BaseURI), 221 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), 222 autorest.WithQueryParameters(queryParameters), 223 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 224 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 225} 226 227// DeleteSender sends the Delete request. The method will close the 228// http.Response Body if it receives an error. 229func (client APIReleaseClient) DeleteSender(req *http.Request) (*http.Response, error) { 230 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 231 return autorest.SendWithSender(client, req, sd...) 232} 233 234// DeleteResponder handles the response to the Delete request. The method always 235// closes the http.Response Body. 236func (client APIReleaseClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 237 err = autorest.Respond( 238 resp, 239 client.ByInspecting(), 240 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 241 autorest.ByClosing()) 242 result.Response = resp 243 return 244} 245 246// Get returns the details of an API release. 247// Parameters: 248// resourceGroupName - the name of the resource group. 249// serviceName - the name of the API Management service. 250// apiid - API identifier. Must be unique in the current API Management service instance. 251// releaseID - release identifier within an API. Must be unique in the current API Management service instance. 252func (client APIReleaseClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result APIReleaseContract, err error) { 253 if tracing.IsEnabled() { 254 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Get") 255 defer func() { 256 sc := -1 257 if result.Response.Response != nil { 258 sc = result.Response.Response.StatusCode 259 } 260 tracing.EndSpan(ctx, sc, err) 261 }() 262 } 263 if err := validation.Validate([]validation.Validation{ 264 {TargetValue: serviceName, 265 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 266 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 267 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 268 {TargetValue: apiid, 269 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 270 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 271 {TargetValue: releaseID, 272 Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 273 {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, 274 {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 275 return result, validation.NewError("apimanagement.APIReleaseClient", "Get", err.Error()) 276 } 277 278 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid, releaseID) 279 if err != nil { 280 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", nil, "Failure preparing request") 281 return 282 } 283 284 resp, err := client.GetSender(req) 285 if err != nil { 286 result.Response = autorest.Response{Response: resp} 287 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", resp, "Failure sending request") 288 return 289 } 290 291 result, err = client.GetResponder(resp) 292 if err != nil { 293 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Get", resp, "Failure responding to request") 294 } 295 296 return 297} 298 299// GetPreparer prepares the Get request. 300func (client APIReleaseClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (*http.Request, error) { 301 pathParameters := map[string]interface{}{ 302 "apiId": autorest.Encode("path", apiid), 303 "releaseId": autorest.Encode("path", releaseID), 304 "resourceGroupName": autorest.Encode("path", resourceGroupName), 305 "serviceName": autorest.Encode("path", serviceName), 306 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 307 } 308 309 const APIVersion = "2019-01-01" 310 queryParameters := map[string]interface{}{ 311 "api-version": APIVersion, 312 } 313 314 preparer := autorest.CreatePreparer( 315 autorest.AsGet(), 316 autorest.WithBaseURL(client.BaseURI), 317 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), 318 autorest.WithQueryParameters(queryParameters)) 319 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 320} 321 322// GetSender sends the Get request. The method will close the 323// http.Response Body if it receives an error. 324func (client APIReleaseClient) GetSender(req *http.Request) (*http.Response, error) { 325 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 326 return autorest.SendWithSender(client, req, sd...) 327} 328 329// GetResponder handles the response to the Get request. The method always 330// closes the http.Response Body. 331func (client APIReleaseClient) GetResponder(resp *http.Response) (result APIReleaseContract, err error) { 332 err = autorest.Respond( 333 resp, 334 client.ByInspecting(), 335 azure.WithErrorUnlessStatusCode(http.StatusOK), 336 autorest.ByUnmarshallingJSON(&result), 337 autorest.ByClosing()) 338 result.Response = autorest.Response{Response: resp} 339 return 340} 341 342// GetEntityTag returns the etag of an API release. 343// Parameters: 344// resourceGroupName - the name of the resource group. 345// serviceName - the name of the API Management service. 346// apiid - API identifier. Must be unique in the current API Management service instance. 347// releaseID - release identifier within an API. Must be unique in the current API Management service instance. 348func (client APIReleaseClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (result autorest.Response, err error) { 349 if tracing.IsEnabled() { 350 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.GetEntityTag") 351 defer func() { 352 sc := -1 353 if result.Response != nil { 354 sc = result.Response.StatusCode 355 } 356 tracing.EndSpan(ctx, sc, err) 357 }() 358 } 359 if err := validation.Validate([]validation.Validation{ 360 {TargetValue: serviceName, 361 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 362 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 363 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 364 {TargetValue: apiid, 365 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 366 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 367 {TargetValue: releaseID, 368 Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 369 {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, 370 {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 371 return result, validation.NewError("apimanagement.APIReleaseClient", "GetEntityTag", err.Error()) 372 } 373 374 req, err := client.GetEntityTagPreparer(ctx, resourceGroupName, serviceName, apiid, releaseID) 375 if err != nil { 376 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", nil, "Failure preparing request") 377 return 378 } 379 380 resp, err := client.GetEntityTagSender(req) 381 if err != nil { 382 result.Response = resp 383 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", resp, "Failure sending request") 384 return 385 } 386 387 result, err = client.GetEntityTagResponder(resp) 388 if err != nil { 389 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "GetEntityTag", resp, "Failure responding to request") 390 } 391 392 return 393} 394 395// GetEntityTagPreparer prepares the GetEntityTag request. 396func (client APIReleaseClient) GetEntityTagPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string) (*http.Request, error) { 397 pathParameters := map[string]interface{}{ 398 "apiId": autorest.Encode("path", apiid), 399 "releaseId": autorest.Encode("path", releaseID), 400 "resourceGroupName": autorest.Encode("path", resourceGroupName), 401 "serviceName": autorest.Encode("path", serviceName), 402 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 403 } 404 405 const APIVersion = "2019-01-01" 406 queryParameters := map[string]interface{}{ 407 "api-version": APIVersion, 408 } 409 410 preparer := autorest.CreatePreparer( 411 autorest.AsHead(), 412 autorest.WithBaseURL(client.BaseURI), 413 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), 414 autorest.WithQueryParameters(queryParameters)) 415 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 416} 417 418// GetEntityTagSender sends the GetEntityTag request. The method will close the 419// http.Response Body if it receives an error. 420func (client APIReleaseClient) GetEntityTagSender(req *http.Request) (*http.Response, error) { 421 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 422 return autorest.SendWithSender(client, req, sd...) 423} 424 425// GetEntityTagResponder handles the response to the GetEntityTag request. The method always 426// closes the http.Response Body. 427func (client APIReleaseClient) GetEntityTagResponder(resp *http.Response) (result autorest.Response, err error) { 428 err = autorest.Respond( 429 resp, 430 client.ByInspecting(), 431 azure.WithErrorUnlessStatusCode(http.StatusOK), 432 autorest.ByClosing()) 433 result.Response = resp 434 return 435} 436 437// ListByService lists all releases of an API. An API release is created when making an API Revision current. Releases 438// are also used to rollback to previous revisions. Results will be paged and can be constrained by the $top and $skip 439// parameters. 440// Parameters: 441// resourceGroupName - the name of the resource group. 442// serviceName - the name of the API Management service. 443// apiid - API identifier. Must be unique in the current API Management service instance. 444// filter - | Field | Usage | Supported operators | Supported functions 445// |</br>|-------------|-------------|-------------|-------------|</br>| notes | filter | ge, le, eq, ne, gt, 446// lt | substringof, contains, startswith, endswith | </br> 447// top - number of records to return. 448// skip - number of records to skip. 449func (client APIReleaseClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIReleaseCollectionPage, err error) { 450 if tracing.IsEnabled() { 451 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.ListByService") 452 defer func() { 453 sc := -1 454 if result.arc.Response.Response != nil { 455 sc = result.arc.Response.Response.StatusCode 456 } 457 tracing.EndSpan(ctx, sc, err) 458 }() 459 } 460 if err := validation.Validate([]validation.Validation{ 461 {TargetValue: serviceName, 462 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 463 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 464 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 465 {TargetValue: apiid, 466 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 467 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 468 {TargetValue: top, 469 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 470 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, 471 {TargetValue: skip, 472 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 473 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { 474 return result, validation.NewError("apimanagement.APIReleaseClient", "ListByService", err.Error()) 475 } 476 477 result.fn = client.listByServiceNextResults 478 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 479 if err != nil { 480 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", nil, "Failure preparing request") 481 return 482 } 483 484 resp, err := client.ListByServiceSender(req) 485 if err != nil { 486 result.arc.Response = autorest.Response{Response: resp} 487 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", resp, "Failure sending request") 488 return 489 } 490 491 result.arc, err = client.ListByServiceResponder(resp) 492 if err != nil { 493 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "ListByService", resp, "Failure responding to request") 494 } 495 496 return 497} 498 499// ListByServicePreparer prepares the ListByService request. 500func (client APIReleaseClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { 501 pathParameters := map[string]interface{}{ 502 "apiId": autorest.Encode("path", apiid), 503 "resourceGroupName": autorest.Encode("path", resourceGroupName), 504 "serviceName": autorest.Encode("path", serviceName), 505 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 506 } 507 508 const APIVersion = "2019-01-01" 509 queryParameters := map[string]interface{}{ 510 "api-version": APIVersion, 511 } 512 if len(filter) > 0 { 513 queryParameters["$filter"] = autorest.Encode("query", filter) 514 } 515 if top != nil { 516 queryParameters["$top"] = autorest.Encode("query", *top) 517 } 518 if skip != nil { 519 queryParameters["$skip"] = autorest.Encode("query", *skip) 520 } 521 522 preparer := autorest.CreatePreparer( 523 autorest.AsGet(), 524 autorest.WithBaseURL(client.BaseURI), 525 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases", pathParameters), 526 autorest.WithQueryParameters(queryParameters)) 527 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 528} 529 530// ListByServiceSender sends the ListByService request. The method will close the 531// http.Response Body if it receives an error. 532func (client APIReleaseClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 533 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 534 return autorest.SendWithSender(client, req, sd...) 535} 536 537// ListByServiceResponder handles the response to the ListByService request. The method always 538// closes the http.Response Body. 539func (client APIReleaseClient) ListByServiceResponder(resp *http.Response) (result APIReleaseCollection, err error) { 540 err = autorest.Respond( 541 resp, 542 client.ByInspecting(), 543 azure.WithErrorUnlessStatusCode(http.StatusOK), 544 autorest.ByUnmarshallingJSON(&result), 545 autorest.ByClosing()) 546 result.Response = autorest.Response{Response: resp} 547 return 548} 549 550// listByServiceNextResults retrieves the next set of results, if any. 551func (client APIReleaseClient) listByServiceNextResults(ctx context.Context, lastResults APIReleaseCollection) (result APIReleaseCollection, err error) { 552 req, err := lastResults.aPIReleaseCollectionPreparer(ctx) 553 if err != nil { 554 return result, autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", nil, "Failure preparing next results request") 555 } 556 if req == nil { 557 return 558 } 559 resp, err := client.ListByServiceSender(req) 560 if err != nil { 561 result.Response = autorest.Response{Response: resp} 562 return result, autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", resp, "Failure sending next results request") 563 } 564 result, err = client.ListByServiceResponder(resp) 565 if err != nil { 566 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "listByServiceNextResults", resp, "Failure responding to next results request") 567 } 568 return 569} 570 571// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 572func (client APIReleaseClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result APIReleaseCollectionIterator, err error) { 573 if tracing.IsEnabled() { 574 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.ListByService") 575 defer func() { 576 sc := -1 577 if result.Response().Response.Response != nil { 578 sc = result.page.Response().Response.Response.StatusCode 579 } 580 tracing.EndSpan(ctx, sc, err) 581 }() 582 } 583 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 584 return 585} 586 587// Update updates the details of the release of the API specified by its identifier. 588// Parameters: 589// resourceGroupName - the name of the resource group. 590// serviceName - the name of the API Management service. 591// apiid - API identifier. Must be unique in the current API Management service instance. 592// releaseID - release identifier within an API. Must be unique in the current API Management service instance. 593// parameters - API Release Update parameters. 594// ifMatch - eTag of the Entity. ETag should match the current entity state from the header response of the GET 595// request or it should be * for unconditional update. 596func (client APIReleaseClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (result autorest.Response, err error) { 597 if tracing.IsEnabled() { 598 ctx = tracing.StartSpan(ctx, fqdn+"/APIReleaseClient.Update") 599 defer func() { 600 sc := -1 601 if result.Response != nil { 602 sc = result.Response.StatusCode 603 } 604 tracing.EndSpan(ctx, sc, err) 605 }() 606 } 607 if err := validation.Validate([]validation.Validation{ 608 {TargetValue: serviceName, 609 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 610 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 611 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 612 {TargetValue: apiid, 613 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 80, Chain: nil}, 614 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 615 {TargetValue: releaseID, 616 Constraints: []validation.Constraint{{Target: "releaseID", Name: validation.MaxLength, Rule: 80, Chain: nil}, 617 {Target: "releaseID", Name: validation.MinLength, Rule: 1, Chain: nil}, 618 {Target: "releaseID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 619 return result, validation.NewError("apimanagement.APIReleaseClient", "Update", err.Error()) 620 } 621 622 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, apiid, releaseID, parameters, ifMatch) 623 if err != nil { 624 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", nil, "Failure preparing request") 625 return 626 } 627 628 resp, err := client.UpdateSender(req) 629 if err != nil { 630 result.Response = resp 631 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", resp, "Failure sending request") 632 return 633 } 634 635 result, err = client.UpdateResponder(resp) 636 if err != nil { 637 err = autorest.NewErrorWithError(err, "apimanagement.APIReleaseClient", "Update", resp, "Failure responding to request") 638 } 639 640 return 641} 642 643// UpdatePreparer prepares the Update request. 644func (client APIReleaseClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, releaseID string, parameters APIReleaseContract, ifMatch string) (*http.Request, error) { 645 pathParameters := map[string]interface{}{ 646 "apiId": autorest.Encode("path", apiid), 647 "releaseId": autorest.Encode("path", releaseID), 648 "resourceGroupName": autorest.Encode("path", resourceGroupName), 649 "serviceName": autorest.Encode("path", serviceName), 650 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 651 } 652 653 const APIVersion = "2019-01-01" 654 queryParameters := map[string]interface{}{ 655 "api-version": APIVersion, 656 } 657 658 preparer := autorest.CreatePreparer( 659 autorest.AsContentType("application/json; charset=utf-8"), 660 autorest.AsPatch(), 661 autorest.WithBaseURL(client.BaseURI), 662 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}", pathParameters), 663 autorest.WithJSON(parameters), 664 autorest.WithQueryParameters(queryParameters), 665 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 666 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 667} 668 669// UpdateSender sends the Update request. The method will close the 670// http.Response Body if it receives an error. 671func (client APIReleaseClient) UpdateSender(req *http.Request) (*http.Response, error) { 672 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 673 return autorest.SendWithSender(client, req, sd...) 674} 675 676// UpdateResponder handles the response to the Update request. The method always 677// closes the http.Response Body. 678func (client APIReleaseClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) { 679 err = autorest.Respond( 680 resp, 681 client.ByInspecting(), 682 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 683 autorest.ByClosing()) 684 result.Response = resp 685 return 686} 687