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