1package authoring 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 "github.com/satori/go.uuid" 27 "net/http" 28) 29 30// VersionsClient is the client for the Versions methods of the Authoring service. 31type VersionsClient struct { 32 BaseClient 33} 34 35// NewVersionsClient creates an instance of the VersionsClient client. 36func NewVersionsClient(endpoint string) VersionsClient { 37 return VersionsClient{New(endpoint)} 38} 39 40// Clone creates a new version from the selected version. 41// Parameters: 42// appID - the application ID. 43// versionID - the version ID. 44// versionCloneObject - a model containing the new version ID. 45func (client VersionsClient) Clone(ctx context.Context, appID uuid.UUID, versionID string, versionCloneObject TaskUpdateObject) (result String, err error) { 46 if tracing.IsEnabled() { 47 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Clone") 48 defer func() { 49 sc := -1 50 if result.Response.Response != nil { 51 sc = result.Response.Response.StatusCode 52 } 53 tracing.EndSpan(ctx, sc, err) 54 }() 55 } 56 req, err := client.ClonePreparer(ctx, appID, versionID, versionCloneObject) 57 if err != nil { 58 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Clone", nil, "Failure preparing request") 59 return 60 } 61 62 resp, err := client.CloneSender(req) 63 if err != nil { 64 result.Response = autorest.Response{Response: resp} 65 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Clone", resp, "Failure sending request") 66 return 67 } 68 69 result, err = client.CloneResponder(resp) 70 if err != nil { 71 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Clone", resp, "Failure responding to request") 72 return 73 } 74 75 return 76} 77 78// ClonePreparer prepares the Clone request. 79func (client VersionsClient) ClonePreparer(ctx context.Context, appID uuid.UUID, versionID string, versionCloneObject TaskUpdateObject) (*http.Request, error) { 80 urlParameters := map[string]interface{}{ 81 "Endpoint": client.Endpoint, 82 } 83 84 pathParameters := map[string]interface{}{ 85 "appId": autorest.Encode("path", appID), 86 "versionId": autorest.Encode("path", versionID), 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsContentType("application/json; charset=utf-8"), 91 autorest.AsPost(), 92 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 93 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/clone", pathParameters), 94 autorest.WithJSON(versionCloneObject)) 95 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 96} 97 98// CloneSender sends the Clone request. The method will close the 99// http.Response Body if it receives an error. 100func (client VersionsClient) CloneSender(req *http.Request) (*http.Response, error) { 101 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 102} 103 104// CloneResponder handles the response to the Clone request. The method always 105// closes the http.Response Body. 106func (client VersionsClient) CloneResponder(resp *http.Response) (result String, err error) { 107 err = autorest.Respond( 108 resp, 109 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 110 autorest.ByUnmarshallingJSON(&result.Value), 111 autorest.ByClosing()) 112 result.Response = autorest.Response{Response: resp} 113 return 114} 115 116// Delete deletes an application version. 117// Parameters: 118// appID - the application ID. 119// versionID - the version ID. 120func (client VersionsClient) Delete(ctx context.Context, appID uuid.UUID, versionID string) (result OperationStatus, err error) { 121 if tracing.IsEnabled() { 122 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Delete") 123 defer func() { 124 sc := -1 125 if result.Response.Response != nil { 126 sc = result.Response.Response.StatusCode 127 } 128 tracing.EndSpan(ctx, sc, err) 129 }() 130 } 131 req, err := client.DeletePreparer(ctx, appID, versionID) 132 if err != nil { 133 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Delete", nil, "Failure preparing request") 134 return 135 } 136 137 resp, err := client.DeleteSender(req) 138 if err != nil { 139 result.Response = autorest.Response{Response: resp} 140 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Delete", resp, "Failure sending request") 141 return 142 } 143 144 result, err = client.DeleteResponder(resp) 145 if err != nil { 146 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Delete", resp, "Failure responding to request") 147 return 148 } 149 150 return 151} 152 153// DeletePreparer prepares the Delete request. 154func (client VersionsClient) DeletePreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) { 155 urlParameters := map[string]interface{}{ 156 "Endpoint": client.Endpoint, 157 } 158 159 pathParameters := map[string]interface{}{ 160 "appId": autorest.Encode("path", appID), 161 "versionId": autorest.Encode("path", versionID), 162 } 163 164 preparer := autorest.CreatePreparer( 165 autorest.AsDelete(), 166 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 167 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/", pathParameters)) 168 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 169} 170 171// DeleteSender sends the Delete request. The method will close the 172// http.Response Body if it receives an error. 173func (client VersionsClient) DeleteSender(req *http.Request) (*http.Response, error) { 174 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 175} 176 177// DeleteResponder handles the response to the Delete request. The method always 178// closes the http.Response Body. 179func (client VersionsClient) DeleteResponder(resp *http.Response) (result OperationStatus, err error) { 180 err = autorest.Respond( 181 resp, 182 azure.WithErrorUnlessStatusCode(http.StatusOK), 183 autorest.ByUnmarshallingJSON(&result), 184 autorest.ByClosing()) 185 result.Response = autorest.Response{Response: resp} 186 return 187} 188 189// DeleteUnlabelledUtterance deleted an unlabelled utterance in a version of the application. 190// Parameters: 191// appID - the application ID. 192// versionID - the version ID. 193// utterance - the utterance text to delete. 194func (client VersionsClient) DeleteUnlabelledUtterance(ctx context.Context, appID uuid.UUID, versionID string, utterance string) (result OperationStatus, err error) { 195 if tracing.IsEnabled() { 196 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.DeleteUnlabelledUtterance") 197 defer func() { 198 sc := -1 199 if result.Response.Response != nil { 200 sc = result.Response.Response.StatusCode 201 } 202 tracing.EndSpan(ctx, sc, err) 203 }() 204 } 205 req, err := client.DeleteUnlabelledUtterancePreparer(ctx, appID, versionID, utterance) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "DeleteUnlabelledUtterance", nil, "Failure preparing request") 208 return 209 } 210 211 resp, err := client.DeleteUnlabelledUtteranceSender(req) 212 if err != nil { 213 result.Response = autorest.Response{Response: resp} 214 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "DeleteUnlabelledUtterance", resp, "Failure sending request") 215 return 216 } 217 218 result, err = client.DeleteUnlabelledUtteranceResponder(resp) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "DeleteUnlabelledUtterance", resp, "Failure responding to request") 221 return 222 } 223 224 return 225} 226 227// DeleteUnlabelledUtterancePreparer prepares the DeleteUnlabelledUtterance request. 228func (client VersionsClient) DeleteUnlabelledUtterancePreparer(ctx context.Context, appID uuid.UUID, versionID string, utterance string) (*http.Request, error) { 229 urlParameters := map[string]interface{}{ 230 "Endpoint": client.Endpoint, 231 } 232 233 pathParameters := map[string]interface{}{ 234 "appId": autorest.Encode("path", appID), 235 "versionId": autorest.Encode("path", versionID), 236 } 237 238 preparer := autorest.CreatePreparer( 239 autorest.AsContentType("application/json; charset=utf-8"), 240 autorest.AsDelete(), 241 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 242 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/suggest", pathParameters), 243 autorest.WithJSON(utterance)) 244 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 245} 246 247// DeleteUnlabelledUtteranceSender sends the DeleteUnlabelledUtterance request. The method will close the 248// http.Response Body if it receives an error. 249func (client VersionsClient) DeleteUnlabelledUtteranceSender(req *http.Request) (*http.Response, error) { 250 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 251} 252 253// DeleteUnlabelledUtteranceResponder handles the response to the DeleteUnlabelledUtterance request. The method always 254// closes the http.Response Body. 255func (client VersionsClient) DeleteUnlabelledUtteranceResponder(resp *http.Response) (result OperationStatus, err error) { 256 err = autorest.Respond( 257 resp, 258 azure.WithErrorUnlessStatusCode(http.StatusOK), 259 autorest.ByUnmarshallingJSON(&result), 260 autorest.ByClosing()) 261 result.Response = autorest.Response{Response: resp} 262 return 263} 264 265// Export exports a LUIS application to JSON format. 266// Parameters: 267// appID - the application ID. 268// versionID - the version ID. 269func (client VersionsClient) Export(ctx context.Context, appID uuid.UUID, versionID string) (result LuisApp, err error) { 270 if tracing.IsEnabled() { 271 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Export") 272 defer func() { 273 sc := -1 274 if result.Response.Response != nil { 275 sc = result.Response.Response.StatusCode 276 } 277 tracing.EndSpan(ctx, sc, err) 278 }() 279 } 280 req, err := client.ExportPreparer(ctx, appID, versionID) 281 if err != nil { 282 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Export", nil, "Failure preparing request") 283 return 284 } 285 286 resp, err := client.ExportSender(req) 287 if err != nil { 288 result.Response = autorest.Response{Response: resp} 289 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Export", resp, "Failure sending request") 290 return 291 } 292 293 result, err = client.ExportResponder(resp) 294 if err != nil { 295 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Export", resp, "Failure responding to request") 296 return 297 } 298 299 return 300} 301 302// ExportPreparer prepares the Export request. 303func (client VersionsClient) ExportPreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) { 304 urlParameters := map[string]interface{}{ 305 "Endpoint": client.Endpoint, 306 } 307 308 pathParameters := map[string]interface{}{ 309 "appId": autorest.Encode("path", appID), 310 "versionId": autorest.Encode("path", versionID), 311 } 312 313 preparer := autorest.CreatePreparer( 314 autorest.AsGet(), 315 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 316 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/export", pathParameters)) 317 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 318} 319 320// ExportSender sends the Export request. The method will close the 321// http.Response Body if it receives an error. 322func (client VersionsClient) ExportSender(req *http.Request) (*http.Response, error) { 323 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 324} 325 326// ExportResponder handles the response to the Export request. The method always 327// closes the http.Response Body. 328func (client VersionsClient) ExportResponder(resp *http.Response) (result LuisApp, err error) { 329 err = autorest.Respond( 330 resp, 331 azure.WithErrorUnlessStatusCode(http.StatusOK), 332 autorest.ByUnmarshallingJSON(&result), 333 autorest.ByClosing()) 334 result.Response = autorest.Response{Response: resp} 335 return 336} 337 338// ExportLuFormat exports a LUIS application to text format. 339// Parameters: 340// appID - the application ID. 341// versionID - the version ID. 342func (client VersionsClient) ExportLuFormat(ctx context.Context, appID uuid.UUID, versionID string) (result ReadCloser, err error) { 343 if tracing.IsEnabled() { 344 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.ExportLuFormat") 345 defer func() { 346 sc := -1 347 if result.Response.Response != nil { 348 sc = result.Response.Response.StatusCode 349 } 350 tracing.EndSpan(ctx, sc, err) 351 }() 352 } 353 req, err := client.ExportLuFormatPreparer(ctx, appID, versionID) 354 if err != nil { 355 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ExportLuFormat", nil, "Failure preparing request") 356 return 357 } 358 359 resp, err := client.ExportLuFormatSender(req) 360 if err != nil { 361 result.Response = autorest.Response{Response: resp} 362 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ExportLuFormat", resp, "Failure sending request") 363 return 364 } 365 366 result, err = client.ExportLuFormatResponder(resp) 367 if err != nil { 368 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ExportLuFormat", resp, "Failure responding to request") 369 return 370 } 371 372 return 373} 374 375// ExportLuFormatPreparer prepares the ExportLuFormat request. 376func (client VersionsClient) ExportLuFormatPreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) { 377 urlParameters := map[string]interface{}{ 378 "Endpoint": client.Endpoint, 379 } 380 381 pathParameters := map[string]interface{}{ 382 "appId": autorest.Encode("path", appID), 383 "versionId": autorest.Encode("path", versionID), 384 } 385 386 queryParameters := map[string]interface{}{ 387 "format": autorest.Encode("query", "lu"), 388 } 389 390 preparer := autorest.CreatePreparer( 391 autorest.AsGet(), 392 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 393 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/export", pathParameters), 394 autorest.WithQueryParameters(queryParameters)) 395 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 396} 397 398// ExportLuFormatSender sends the ExportLuFormat request. The method will close the 399// http.Response Body if it receives an error. 400func (client VersionsClient) ExportLuFormatSender(req *http.Request) (*http.Response, error) { 401 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 402} 403 404// ExportLuFormatResponder handles the response to the ExportLuFormat request. The method always 405// closes the http.Response Body. 406func (client VersionsClient) ExportLuFormatResponder(resp *http.Response) (result ReadCloser, err error) { 407 result.Value = &resp.Body 408 err = autorest.Respond( 409 resp, 410 azure.WithErrorUnlessStatusCode(http.StatusOK)) 411 result.Response = autorest.Response{Response: resp} 412 return 413} 414 415// Get gets the version information such as date created, last modified date, endpoint URL, count of intents and 416// entities, training and publishing status. 417// Parameters: 418// appID - the application ID. 419// versionID - the version ID. 420func (client VersionsClient) Get(ctx context.Context, appID uuid.UUID, versionID string) (result VersionInfo, err error) { 421 if tracing.IsEnabled() { 422 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Get") 423 defer func() { 424 sc := -1 425 if result.Response.Response != nil { 426 sc = result.Response.Response.StatusCode 427 } 428 tracing.EndSpan(ctx, sc, err) 429 }() 430 } 431 req, err := client.GetPreparer(ctx, appID, versionID) 432 if err != nil { 433 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Get", nil, "Failure preparing request") 434 return 435 } 436 437 resp, err := client.GetSender(req) 438 if err != nil { 439 result.Response = autorest.Response{Response: resp} 440 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Get", resp, "Failure sending request") 441 return 442 } 443 444 result, err = client.GetResponder(resp) 445 if err != nil { 446 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Get", resp, "Failure responding to request") 447 return 448 } 449 450 return 451} 452 453// GetPreparer prepares the Get request. 454func (client VersionsClient) GetPreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) { 455 urlParameters := map[string]interface{}{ 456 "Endpoint": client.Endpoint, 457 } 458 459 pathParameters := map[string]interface{}{ 460 "appId": autorest.Encode("path", appID), 461 "versionId": autorest.Encode("path", versionID), 462 } 463 464 preparer := autorest.CreatePreparer( 465 autorest.AsGet(), 466 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 467 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/", pathParameters)) 468 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 469} 470 471// GetSender sends the Get request. The method will close the 472// http.Response Body if it receives an error. 473func (client VersionsClient) GetSender(req *http.Request) (*http.Response, error) { 474 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 475} 476 477// GetResponder handles the response to the Get request. The method always 478// closes the http.Response Body. 479func (client VersionsClient) GetResponder(resp *http.Response) (result VersionInfo, err error) { 480 err = autorest.Respond( 481 resp, 482 azure.WithErrorUnlessStatusCode(http.StatusOK), 483 autorest.ByUnmarshallingJSON(&result), 484 autorest.ByClosing()) 485 result.Response = autorest.Response{Response: resp} 486 return 487} 488 489// Import imports a new version into a LUIS application. 490// Parameters: 491// appID - the application ID. 492// luisApp - a LUIS application structure. 493// versionID - the new versionId to import. If not specified, the versionId will be read from the imported 494// object. 495func (client VersionsClient) Import(ctx context.Context, appID uuid.UUID, luisApp LuisApp, versionID string) (result String, err error) { 496 if tracing.IsEnabled() { 497 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Import") 498 defer func() { 499 sc := -1 500 if result.Response.Response != nil { 501 sc = result.Response.Response.StatusCode 502 } 503 tracing.EndSpan(ctx, sc, err) 504 }() 505 } 506 req, err := client.ImportPreparer(ctx, appID, luisApp, versionID) 507 if err != nil { 508 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Import", nil, "Failure preparing request") 509 return 510 } 511 512 resp, err := client.ImportSender(req) 513 if err != nil { 514 result.Response = autorest.Response{Response: resp} 515 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Import", resp, "Failure sending request") 516 return 517 } 518 519 result, err = client.ImportResponder(resp) 520 if err != nil { 521 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Import", resp, "Failure responding to request") 522 return 523 } 524 525 return 526} 527 528// ImportPreparer prepares the Import request. 529func (client VersionsClient) ImportPreparer(ctx context.Context, appID uuid.UUID, luisApp LuisApp, versionID string) (*http.Request, error) { 530 urlParameters := map[string]interface{}{ 531 "Endpoint": client.Endpoint, 532 } 533 534 pathParameters := map[string]interface{}{ 535 "appId": autorest.Encode("path", appID), 536 } 537 538 queryParameters := map[string]interface{}{} 539 if len(versionID) > 0 { 540 queryParameters["versionId"] = autorest.Encode("query", versionID) 541 } 542 543 preparer := autorest.CreatePreparer( 544 autorest.AsContentType("application/json; charset=utf-8"), 545 autorest.AsPost(), 546 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 547 autorest.WithPathParameters("/apps/{appId}/versions/import", pathParameters), 548 autorest.WithJSON(luisApp), 549 autorest.WithQueryParameters(queryParameters)) 550 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 551} 552 553// ImportSender sends the Import request. The method will close the 554// http.Response Body if it receives an error. 555func (client VersionsClient) ImportSender(req *http.Request) (*http.Response, error) { 556 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 557} 558 559// ImportResponder handles the response to the Import request. The method always 560// closes the http.Response Body. 561func (client VersionsClient) ImportResponder(resp *http.Response) (result String, err error) { 562 err = autorest.Respond( 563 resp, 564 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 565 autorest.ByUnmarshallingJSON(&result.Value), 566 autorest.ByClosing()) 567 result.Response = autorest.Response{Response: resp} 568 return 569} 570 571// ImportLuFormat imports a new version into a LUIS application. 572// Parameters: 573// appID - the application ID. 574// luisAppLu - an LU representing the LUIS application structure. 575// versionID - the new versionId to import. If not specified, the versionId will be read from the imported 576// object. 577func (client VersionsClient) ImportLuFormat(ctx context.Context, appID uuid.UUID, luisAppLu string, versionID string) (result String, err error) { 578 if tracing.IsEnabled() { 579 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.ImportLuFormat") 580 defer func() { 581 sc := -1 582 if result.Response.Response != nil { 583 sc = result.Response.Response.StatusCode 584 } 585 tracing.EndSpan(ctx, sc, err) 586 }() 587 } 588 req, err := client.ImportLuFormatPreparer(ctx, appID, luisAppLu, versionID) 589 if err != nil { 590 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportLuFormat", nil, "Failure preparing request") 591 return 592 } 593 594 resp, err := client.ImportLuFormatSender(req) 595 if err != nil { 596 result.Response = autorest.Response{Response: resp} 597 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportLuFormat", resp, "Failure sending request") 598 return 599 } 600 601 result, err = client.ImportLuFormatResponder(resp) 602 if err != nil { 603 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportLuFormat", resp, "Failure responding to request") 604 return 605 } 606 607 return 608} 609 610// ImportLuFormatPreparer prepares the ImportLuFormat request. 611func (client VersionsClient) ImportLuFormatPreparer(ctx context.Context, appID uuid.UUID, luisAppLu string, versionID string) (*http.Request, error) { 612 urlParameters := map[string]interface{}{ 613 "Endpoint": client.Endpoint, 614 } 615 616 pathParameters := map[string]interface{}{ 617 "appId": autorest.Encode("path", appID), 618 } 619 620 queryParameters := map[string]interface{}{} 621 if len(versionID) > 0 { 622 queryParameters["versionId"] = autorest.Encode("query", versionID) 623 } 624 625 preparer := autorest.CreatePreparer( 626 autorest.AsContentType("text/plain"), 627 autorest.AsPost(), 628 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 629 autorest.WithPathParameters("/apps/{appId}/versions/import", pathParameters), 630 autorest.WithJSON(luisAppLu), 631 autorest.WithQueryParameters(queryParameters)) 632 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 633} 634 635// ImportLuFormatSender sends the ImportLuFormat request. The method will close the 636// http.Response Body if it receives an error. 637func (client VersionsClient) ImportLuFormatSender(req *http.Request) (*http.Response, error) { 638 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 639} 640 641// ImportLuFormatResponder handles the response to the ImportLuFormat request. The method always 642// closes the http.Response Body. 643func (client VersionsClient) ImportLuFormatResponder(resp *http.Response) (result String, err error) { 644 err = autorest.Respond( 645 resp, 646 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 647 autorest.ByUnmarshallingJSON(&result.Value), 648 autorest.ByClosing()) 649 result.Response = autorest.Response{Response: resp} 650 return 651} 652 653// ImportV2App imports a new version into a LUIS application. 654// Parameters: 655// appID - the application ID. 656// luisAppV2 - a LUIS application structure. 657// versionID - the new versionId to import. If not specified, the versionId will be read from the imported 658// object. 659func (client VersionsClient) ImportV2App(ctx context.Context, appID uuid.UUID, luisAppV2 LuisAppV2, versionID string) (result String, err error) { 660 if tracing.IsEnabled() { 661 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.ImportV2App") 662 defer func() { 663 sc := -1 664 if result.Response.Response != nil { 665 sc = result.Response.Response.StatusCode 666 } 667 tracing.EndSpan(ctx, sc, err) 668 }() 669 } 670 req, err := client.ImportV2AppPreparer(ctx, appID, luisAppV2, versionID) 671 if err != nil { 672 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportV2App", nil, "Failure preparing request") 673 return 674 } 675 676 resp, err := client.ImportV2AppSender(req) 677 if err != nil { 678 result.Response = autorest.Response{Response: resp} 679 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportV2App", resp, "Failure sending request") 680 return 681 } 682 683 result, err = client.ImportV2AppResponder(resp) 684 if err != nil { 685 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "ImportV2App", resp, "Failure responding to request") 686 return 687 } 688 689 return 690} 691 692// ImportV2AppPreparer prepares the ImportV2App request. 693func (client VersionsClient) ImportV2AppPreparer(ctx context.Context, appID uuid.UUID, luisAppV2 LuisAppV2, versionID string) (*http.Request, error) { 694 urlParameters := map[string]interface{}{ 695 "Endpoint": client.Endpoint, 696 } 697 698 pathParameters := map[string]interface{}{ 699 "appId": autorest.Encode("path", appID), 700 } 701 702 queryParameters := map[string]interface{}{} 703 if len(versionID) > 0 { 704 queryParameters["versionId"] = autorest.Encode("query", versionID) 705 } 706 707 preparer := autorest.CreatePreparer( 708 autorest.AsContentType("application/json; charset=utf-8"), 709 autorest.AsPost(), 710 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 711 autorest.WithPathParameters("/apps/{appId}/versions/import", pathParameters), 712 autorest.WithJSON(luisAppV2), 713 autorest.WithQueryParameters(queryParameters)) 714 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 715} 716 717// ImportV2AppSender sends the ImportV2App request. The method will close the 718// http.Response Body if it receives an error. 719func (client VersionsClient) ImportV2AppSender(req *http.Request) (*http.Response, error) { 720 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 721} 722 723// ImportV2AppResponder handles the response to the ImportV2App request. The method always 724// closes the http.Response Body. 725func (client VersionsClient) ImportV2AppResponder(resp *http.Response) (result String, err error) { 726 err = autorest.Respond( 727 resp, 728 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 729 autorest.ByUnmarshallingJSON(&result.Value), 730 autorest.ByClosing()) 731 result.Response = autorest.Response{Response: resp} 732 return 733} 734 735// List gets a list of versions for this application ID. 736// Parameters: 737// appID - the application ID. 738// skip - the number of entries to skip. Default value is 0. 739// take - the number of entries to return. Maximum page size is 500. Default is 100. 740func (client VersionsClient) List(ctx context.Context, appID uuid.UUID, skip *int32, take *int32) (result ListVersionInfo, err error) { 741 if tracing.IsEnabled() { 742 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.List") 743 defer func() { 744 sc := -1 745 if result.Response.Response != nil { 746 sc = result.Response.Response.StatusCode 747 } 748 tracing.EndSpan(ctx, sc, err) 749 }() 750 } 751 if err := validation.Validate([]validation.Validation{ 752 {TargetValue: skip, 753 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 754 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}}, 755 {TargetValue: take, 756 Constraints: []validation.Constraint{{Target: "take", Name: validation.Null, Rule: false, 757 Chain: []validation.Constraint{{Target: "take", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil}, 758 {Target: "take", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, 759 }}}}}); err != nil { 760 return result, validation.NewError("authoring.VersionsClient", "List", err.Error()) 761 } 762 763 req, err := client.ListPreparer(ctx, appID, skip, take) 764 if err != nil { 765 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "List", nil, "Failure preparing request") 766 return 767 } 768 769 resp, err := client.ListSender(req) 770 if err != nil { 771 result.Response = autorest.Response{Response: resp} 772 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "List", resp, "Failure sending request") 773 return 774 } 775 776 result, err = client.ListResponder(resp) 777 if err != nil { 778 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "List", resp, "Failure responding to request") 779 return 780 } 781 782 return 783} 784 785// ListPreparer prepares the List request. 786func (client VersionsClient) ListPreparer(ctx context.Context, appID uuid.UUID, skip *int32, take *int32) (*http.Request, error) { 787 urlParameters := map[string]interface{}{ 788 "Endpoint": client.Endpoint, 789 } 790 791 pathParameters := map[string]interface{}{ 792 "appId": autorest.Encode("path", appID), 793 } 794 795 queryParameters := map[string]interface{}{} 796 if skip != nil { 797 queryParameters["skip"] = autorest.Encode("query", *skip) 798 } else { 799 queryParameters["skip"] = autorest.Encode("query", 0) 800 } 801 if take != nil { 802 queryParameters["take"] = autorest.Encode("query", *take) 803 } else { 804 queryParameters["take"] = autorest.Encode("query", 100) 805 } 806 807 preparer := autorest.CreatePreparer( 808 autorest.AsGet(), 809 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 810 autorest.WithPathParameters("/apps/{appId}/versions", pathParameters), 811 autorest.WithQueryParameters(queryParameters)) 812 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 813} 814 815// ListSender sends the List request. The method will close the 816// http.Response Body if it receives an error. 817func (client VersionsClient) ListSender(req *http.Request) (*http.Response, error) { 818 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 819} 820 821// ListResponder handles the response to the List request. The method always 822// closes the http.Response Body. 823func (client VersionsClient) ListResponder(resp *http.Response) (result ListVersionInfo, err error) { 824 err = autorest.Respond( 825 resp, 826 azure.WithErrorUnlessStatusCode(http.StatusOK), 827 autorest.ByUnmarshallingJSON(&result.Value), 828 autorest.ByClosing()) 829 result.Response = autorest.Response{Response: resp} 830 return 831} 832 833// Update updates the name or description of the application version. 834// Parameters: 835// appID - the application ID. 836// versionID - the version ID. 837// versionUpdateObject - a model containing Name and Description of the application. 838func (client VersionsClient) Update(ctx context.Context, appID uuid.UUID, versionID string, versionUpdateObject TaskUpdateObject) (result OperationStatus, err error) { 839 if tracing.IsEnabled() { 840 ctx = tracing.StartSpan(ctx, fqdn+"/VersionsClient.Update") 841 defer func() { 842 sc := -1 843 if result.Response.Response != nil { 844 sc = result.Response.Response.StatusCode 845 } 846 tracing.EndSpan(ctx, sc, err) 847 }() 848 } 849 req, err := client.UpdatePreparer(ctx, appID, versionID, versionUpdateObject) 850 if err != nil { 851 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Update", nil, "Failure preparing request") 852 return 853 } 854 855 resp, err := client.UpdateSender(req) 856 if err != nil { 857 result.Response = autorest.Response{Response: resp} 858 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Update", resp, "Failure sending request") 859 return 860 } 861 862 result, err = client.UpdateResponder(resp) 863 if err != nil { 864 err = autorest.NewErrorWithError(err, "authoring.VersionsClient", "Update", resp, "Failure responding to request") 865 return 866 } 867 868 return 869} 870 871// UpdatePreparer prepares the Update request. 872func (client VersionsClient) UpdatePreparer(ctx context.Context, appID uuid.UUID, versionID string, versionUpdateObject TaskUpdateObject) (*http.Request, error) { 873 urlParameters := map[string]interface{}{ 874 "Endpoint": client.Endpoint, 875 } 876 877 pathParameters := map[string]interface{}{ 878 "appId": autorest.Encode("path", appID), 879 "versionId": autorest.Encode("path", versionID), 880 } 881 882 preparer := autorest.CreatePreparer( 883 autorest.AsContentType("application/json; charset=utf-8"), 884 autorest.AsPut(), 885 autorest.WithCustomBaseURL("{Endpoint}/luis/authoring/v3.0-preview", urlParameters), 886 autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/", pathParameters), 887 autorest.WithJSON(versionUpdateObject)) 888 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 889} 890 891// UpdateSender sends the Update request. The method will close the 892// http.Response Body if it receives an error. 893func (client VersionsClient) UpdateSender(req *http.Request) (*http.Response, error) { 894 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 895} 896 897// UpdateResponder handles the response to the Update request. The method always 898// closes the http.Response Body. 899func (client VersionsClient) UpdateResponder(resp *http.Response) (result OperationStatus, err error) { 900 err = autorest.Respond( 901 resp, 902 azure.WithErrorUnlessStatusCode(http.StatusOK), 903 autorest.ByUnmarshallingJSON(&result), 904 autorest.ByClosing()) 905 result.Response = autorest.Response{Response: resp} 906 return 907} 908