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