...

Source file src/github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/authoring/apps.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/authoring

     1  package authoring
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"github.com/gofrs/uuid"
    16  	"net/http"
    17  )
    18  
    19  // AppsClient is the client for the Apps methods of the Authoring service.
    20  type AppsClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewAppsClient creates an instance of the AppsClient client.
    25  func NewAppsClient(endpoint string) AppsClient {
    26  	return AppsClient{New(endpoint)}
    27  }
    28  
    29  // Add creates a new LUIS app.
    30  // Parameters:
    31  // applicationCreateObject - an application containing Name, Description (optional), Culture, Usage Scenario
    32  // (optional), Domain (optional) and initial version ID (optional) of the application. Default value for the
    33  // version ID is "0.1". Note: the culture cannot be changed after the app is created.
    34  func (client AppsClient) Add(ctx context.Context, applicationCreateObject ApplicationCreateObject) (result UUID, err error) {
    35  	if tracing.IsEnabled() {
    36  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Add")
    37  		defer func() {
    38  			sc := -1
    39  			if result.Response.Response != nil {
    40  				sc = result.Response.Response.StatusCode
    41  			}
    42  			tracing.EndSpan(ctx, sc, err)
    43  		}()
    44  	}
    45  	if err := validation.Validate([]validation.Validation{
    46  		{TargetValue: applicationCreateObject,
    47  			Constraints: []validation.Constraint{{Target: "applicationCreateObject.Culture", Name: validation.Null, Rule: true, Chain: nil},
    48  				{Target: "applicationCreateObject.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
    49  		return result, validation.NewError("authoring.AppsClient", "Add", err.Error())
    50  	}
    51  
    52  	req, err := client.AddPreparer(ctx, applicationCreateObject)
    53  	if err != nil {
    54  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Add", nil, "Failure preparing request")
    55  		return
    56  	}
    57  
    58  	resp, err := client.AddSender(req)
    59  	if err != nil {
    60  		result.Response = autorest.Response{Response: resp}
    61  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Add", resp, "Failure sending request")
    62  		return
    63  	}
    64  
    65  	result, err = client.AddResponder(resp)
    66  	if err != nil {
    67  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Add", resp, "Failure responding to request")
    68  		return
    69  	}
    70  
    71  	return
    72  }
    73  
    74  // AddPreparer prepares the Add request.
    75  func (client AppsClient) AddPreparer(ctx context.Context, applicationCreateObject ApplicationCreateObject) (*http.Request, error) {
    76  	urlParameters := map[string]interface{}{
    77  		"Endpoint": client.Endpoint,
    78  	}
    79  
    80  	preparer := autorest.CreatePreparer(
    81  		autorest.AsContentType("application/json; charset=utf-8"),
    82  		autorest.AsPost(),
    83  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
    84  		autorest.WithPath("/apps/"),
    85  		autorest.WithJSON(applicationCreateObject))
    86  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    87  }
    88  
    89  // AddSender sends the Add request. The method will close the
    90  // http.Response Body if it receives an error.
    91  func (client AppsClient) AddSender(req *http.Request) (*http.Response, error) {
    92  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    93  }
    94  
    95  // AddResponder handles the response to the Add request. The method always
    96  // closes the http.Response Body.
    97  func (client AppsClient) AddResponder(resp *http.Response) (result UUID, err error) {
    98  	err = autorest.Respond(
    99  		resp,
   100  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   101  		autorest.ByUnmarshallingJSON(&result.Value),
   102  		autorest.ByClosing())
   103  	result.Response = autorest.Response{Response: resp}
   104  	return
   105  }
   106  
   107  // AddCustomPrebuiltDomain adds a prebuilt domain along with its intent and entity models as a new application.
   108  // Parameters:
   109  // prebuiltDomainCreateObject - a prebuilt domain create object containing the name and culture of the domain.
   110  func (client AppsClient) AddCustomPrebuiltDomain(ctx context.Context, prebuiltDomainCreateObject PrebuiltDomainCreateObject) (result UUID, err error) {
   111  	if tracing.IsEnabled() {
   112  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.AddCustomPrebuiltDomain")
   113  		defer func() {
   114  			sc := -1
   115  			if result.Response.Response != nil {
   116  				sc = result.Response.Response.StatusCode
   117  			}
   118  			tracing.EndSpan(ctx, sc, err)
   119  		}()
   120  	}
   121  	req, err := client.AddCustomPrebuiltDomainPreparer(ctx, prebuiltDomainCreateObject)
   122  	if err != nil {
   123  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "AddCustomPrebuiltDomain", nil, "Failure preparing request")
   124  		return
   125  	}
   126  
   127  	resp, err := client.AddCustomPrebuiltDomainSender(req)
   128  	if err != nil {
   129  		result.Response = autorest.Response{Response: resp}
   130  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "AddCustomPrebuiltDomain", resp, "Failure sending request")
   131  		return
   132  	}
   133  
   134  	result, err = client.AddCustomPrebuiltDomainResponder(resp)
   135  	if err != nil {
   136  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "AddCustomPrebuiltDomain", resp, "Failure responding to request")
   137  		return
   138  	}
   139  
   140  	return
   141  }
   142  
   143  // AddCustomPrebuiltDomainPreparer prepares the AddCustomPrebuiltDomain request.
   144  func (client AppsClient) AddCustomPrebuiltDomainPreparer(ctx context.Context, prebuiltDomainCreateObject PrebuiltDomainCreateObject) (*http.Request, error) {
   145  	urlParameters := map[string]interface{}{
   146  		"Endpoint": client.Endpoint,
   147  	}
   148  
   149  	preparer := autorest.CreatePreparer(
   150  		autorest.AsContentType("application/json; charset=utf-8"),
   151  		autorest.AsPost(),
   152  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   153  		autorest.WithPath("/apps/customprebuiltdomains"),
   154  		autorest.WithJSON(prebuiltDomainCreateObject))
   155  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   156  }
   157  
   158  // AddCustomPrebuiltDomainSender sends the AddCustomPrebuiltDomain request. The method will close the
   159  // http.Response Body if it receives an error.
   160  func (client AppsClient) AddCustomPrebuiltDomainSender(req *http.Request) (*http.Response, error) {
   161  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   162  }
   163  
   164  // AddCustomPrebuiltDomainResponder handles the response to the AddCustomPrebuiltDomain request. The method always
   165  // closes the http.Response Body.
   166  func (client AppsClient) AddCustomPrebuiltDomainResponder(resp *http.Response) (result UUID, err error) {
   167  	err = autorest.Respond(
   168  		resp,
   169  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   170  		autorest.ByUnmarshallingJSON(&result.Value),
   171  		autorest.ByClosing())
   172  	result.Response = autorest.Response{Response: resp}
   173  	return
   174  }
   175  
   176  // Delete deletes an application.
   177  // Parameters:
   178  // appID - the application ID.
   179  // force - a flag to indicate whether to force an operation.
   180  func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID, force *bool) (result OperationStatus, err error) {
   181  	if tracing.IsEnabled() {
   182  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Delete")
   183  		defer func() {
   184  			sc := -1
   185  			if result.Response.Response != nil {
   186  				sc = result.Response.Response.StatusCode
   187  			}
   188  			tracing.EndSpan(ctx, sc, err)
   189  		}()
   190  	}
   191  	req, err := client.DeletePreparer(ctx, appID, force)
   192  	if err != nil {
   193  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Delete", nil, "Failure preparing request")
   194  		return
   195  	}
   196  
   197  	resp, err := client.DeleteSender(req)
   198  	if err != nil {
   199  		result.Response = autorest.Response{Response: resp}
   200  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Delete", resp, "Failure sending request")
   201  		return
   202  	}
   203  
   204  	result, err = client.DeleteResponder(resp)
   205  	if err != nil {
   206  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Delete", resp, "Failure responding to request")
   207  		return
   208  	}
   209  
   210  	return
   211  }
   212  
   213  // DeletePreparer prepares the Delete request.
   214  func (client AppsClient) DeletePreparer(ctx context.Context, appID uuid.UUID, force *bool) (*http.Request, error) {
   215  	urlParameters := map[string]interface{}{
   216  		"Endpoint": client.Endpoint,
   217  	}
   218  
   219  	pathParameters := map[string]interface{}{
   220  		"appId": autorest.Encode("path", appID),
   221  	}
   222  
   223  	queryParameters := map[string]interface{}{}
   224  	if force != nil {
   225  		queryParameters["force"] = autorest.Encode("query", *force)
   226  	} else {
   227  		queryParameters["force"] = autorest.Encode("query", false)
   228  	}
   229  
   230  	preparer := autorest.CreatePreparer(
   231  		autorest.AsDelete(),
   232  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   233  		autorest.WithPathParameters("/apps/{appId}", pathParameters),
   234  		autorest.WithQueryParameters(queryParameters))
   235  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   236  }
   237  
   238  // DeleteSender sends the Delete request. The method will close the
   239  // http.Response Body if it receives an error.
   240  func (client AppsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   241  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   242  }
   243  
   244  // DeleteResponder handles the response to the Delete request. The method always
   245  // closes the http.Response Body.
   246  func (client AppsClient) DeleteResponder(resp *http.Response) (result OperationStatus, err error) {
   247  	err = autorest.Respond(
   248  		resp,
   249  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   250  		autorest.ByUnmarshallingJSON(&result),
   251  		autorest.ByClosing())
   252  	result.Response = autorest.Response{Response: resp}
   253  	return
   254  }
   255  
   256  // DownloadQueryLogs gets the logs of the past month's endpoint queries for the application.
   257  // Parameters:
   258  // appID - the application ID.
   259  func (client AppsClient) DownloadQueryLogs(ctx context.Context, appID uuid.UUID) (result ReadCloser, err error) {
   260  	if tracing.IsEnabled() {
   261  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.DownloadQueryLogs")
   262  		defer func() {
   263  			sc := -1
   264  			if result.Response.Response != nil {
   265  				sc = result.Response.Response.StatusCode
   266  			}
   267  			tracing.EndSpan(ctx, sc, err)
   268  		}()
   269  	}
   270  	req, err := client.DownloadQueryLogsPreparer(ctx, appID)
   271  	if err != nil {
   272  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "DownloadQueryLogs", nil, "Failure preparing request")
   273  		return
   274  	}
   275  
   276  	resp, err := client.DownloadQueryLogsSender(req)
   277  	if err != nil {
   278  		result.Response = autorest.Response{Response: resp}
   279  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "DownloadQueryLogs", resp, "Failure sending request")
   280  		return
   281  	}
   282  
   283  	result, err = client.DownloadQueryLogsResponder(resp)
   284  	if err != nil {
   285  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "DownloadQueryLogs", resp, "Failure responding to request")
   286  		return
   287  	}
   288  
   289  	return
   290  }
   291  
   292  // DownloadQueryLogsPreparer prepares the DownloadQueryLogs request.
   293  func (client AppsClient) DownloadQueryLogsPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) {
   294  	urlParameters := map[string]interface{}{
   295  		"Endpoint": client.Endpoint,
   296  	}
   297  
   298  	pathParameters := map[string]interface{}{
   299  		"appId": autorest.Encode("path", appID),
   300  	}
   301  
   302  	preparer := autorest.CreatePreparer(
   303  		autorest.AsGet(),
   304  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   305  		autorest.WithPathParameters("/apps/{appId}/querylogs", pathParameters))
   306  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   307  }
   308  
   309  // DownloadQueryLogsSender sends the DownloadQueryLogs request. The method will close the
   310  // http.Response Body if it receives an error.
   311  func (client AppsClient) DownloadQueryLogsSender(req *http.Request) (*http.Response, error) {
   312  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   313  }
   314  
   315  // DownloadQueryLogsResponder handles the response to the DownloadQueryLogs request. The method always
   316  // closes the http.Response Body.
   317  func (client AppsClient) DownloadQueryLogsResponder(resp *http.Response) (result ReadCloser, err error) {
   318  	result.Value = &resp.Body
   319  	err = autorest.Respond(
   320  		resp,
   321  		azure.WithErrorUnlessStatusCode(http.StatusOK))
   322  	result.Response = autorest.Response{Response: resp}
   323  	return
   324  }
   325  
   326  // Get gets the application info.
   327  // Parameters:
   328  // appID - the application ID.
   329  func (client AppsClient) Get(ctx context.Context, appID uuid.UUID) (result ApplicationInfoResponse, err error) {
   330  	if tracing.IsEnabled() {
   331  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Get")
   332  		defer func() {
   333  			sc := -1
   334  			if result.Response.Response != nil {
   335  				sc = result.Response.Response.StatusCode
   336  			}
   337  			tracing.EndSpan(ctx, sc, err)
   338  		}()
   339  	}
   340  	req, err := client.GetPreparer(ctx, appID)
   341  	if err != nil {
   342  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Get", nil, "Failure preparing request")
   343  		return
   344  	}
   345  
   346  	resp, err := client.GetSender(req)
   347  	if err != nil {
   348  		result.Response = autorest.Response{Response: resp}
   349  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Get", resp, "Failure sending request")
   350  		return
   351  	}
   352  
   353  	result, err = client.GetResponder(resp)
   354  	if err != nil {
   355  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Get", resp, "Failure responding to request")
   356  		return
   357  	}
   358  
   359  	return
   360  }
   361  
   362  // GetPreparer prepares the Get request.
   363  func (client AppsClient) GetPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) {
   364  	urlParameters := map[string]interface{}{
   365  		"Endpoint": client.Endpoint,
   366  	}
   367  
   368  	pathParameters := map[string]interface{}{
   369  		"appId": autorest.Encode("path", appID),
   370  	}
   371  
   372  	preparer := autorest.CreatePreparer(
   373  		autorest.AsGet(),
   374  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   375  		autorest.WithPathParameters("/apps/{appId}", pathParameters))
   376  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   377  }
   378  
   379  // GetSender sends the Get request. The method will close the
   380  // http.Response Body if it receives an error.
   381  func (client AppsClient) GetSender(req *http.Request) (*http.Response, error) {
   382  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   383  }
   384  
   385  // GetResponder handles the response to the Get request. The method always
   386  // closes the http.Response Body.
   387  func (client AppsClient) GetResponder(resp *http.Response) (result ApplicationInfoResponse, err error) {
   388  	err = autorest.Respond(
   389  		resp,
   390  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   391  		autorest.ByUnmarshallingJSON(&result),
   392  		autorest.ByClosing())
   393  	result.Response = autorest.Response{Response: resp}
   394  	return
   395  }
   396  
   397  // GetPublishSettings get the application publish settings including 'UseAllTrainingData'.
   398  // Parameters:
   399  // appID - the application ID.
   400  func (client AppsClient) GetPublishSettings(ctx context.Context, appID uuid.UUID) (result PublishSettings, err error) {
   401  	if tracing.IsEnabled() {
   402  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.GetPublishSettings")
   403  		defer func() {
   404  			sc := -1
   405  			if result.Response.Response != nil {
   406  				sc = result.Response.Response.StatusCode
   407  			}
   408  			tracing.EndSpan(ctx, sc, err)
   409  		}()
   410  	}
   411  	req, err := client.GetPublishSettingsPreparer(ctx, appID)
   412  	if err != nil {
   413  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetPublishSettings", nil, "Failure preparing request")
   414  		return
   415  	}
   416  
   417  	resp, err := client.GetPublishSettingsSender(req)
   418  	if err != nil {
   419  		result.Response = autorest.Response{Response: resp}
   420  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetPublishSettings", resp, "Failure sending request")
   421  		return
   422  	}
   423  
   424  	result, err = client.GetPublishSettingsResponder(resp)
   425  	if err != nil {
   426  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetPublishSettings", resp, "Failure responding to request")
   427  		return
   428  	}
   429  
   430  	return
   431  }
   432  
   433  // GetPublishSettingsPreparer prepares the GetPublishSettings request.
   434  func (client AppsClient) GetPublishSettingsPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) {
   435  	urlParameters := map[string]interface{}{
   436  		"Endpoint": client.Endpoint,
   437  	}
   438  
   439  	pathParameters := map[string]interface{}{
   440  		"appId": autorest.Encode("path", appID),
   441  	}
   442  
   443  	preparer := autorest.CreatePreparer(
   444  		autorest.AsGet(),
   445  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   446  		autorest.WithPathParameters("/apps/{appId}/publishsettings", pathParameters))
   447  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   448  }
   449  
   450  // GetPublishSettingsSender sends the GetPublishSettings request. The method will close the
   451  // http.Response Body if it receives an error.
   452  func (client AppsClient) GetPublishSettingsSender(req *http.Request) (*http.Response, error) {
   453  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   454  }
   455  
   456  // GetPublishSettingsResponder handles the response to the GetPublishSettings request. The method always
   457  // closes the http.Response Body.
   458  func (client AppsClient) GetPublishSettingsResponder(resp *http.Response) (result PublishSettings, err error) {
   459  	err = autorest.Respond(
   460  		resp,
   461  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   462  		autorest.ByUnmarshallingJSON(&result),
   463  		autorest.ByClosing())
   464  	result.Response = autorest.Response{Response: resp}
   465  	return
   466  }
   467  
   468  // GetSettings get the application settings including 'UseAllTrainingData'.
   469  // Parameters:
   470  // appID - the application ID.
   471  func (client AppsClient) GetSettings(ctx context.Context, appID uuid.UUID) (result ApplicationSettings, err error) {
   472  	if tracing.IsEnabled() {
   473  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.GetSettings")
   474  		defer func() {
   475  			sc := -1
   476  			if result.Response.Response != nil {
   477  				sc = result.Response.Response.StatusCode
   478  			}
   479  			tracing.EndSpan(ctx, sc, err)
   480  		}()
   481  	}
   482  	req, err := client.GetSettingsPreparer(ctx, appID)
   483  	if err != nil {
   484  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetSettings", nil, "Failure preparing request")
   485  		return
   486  	}
   487  
   488  	resp, err := client.GetSettingsSender(req)
   489  	if err != nil {
   490  		result.Response = autorest.Response{Response: resp}
   491  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetSettings", resp, "Failure sending request")
   492  		return
   493  	}
   494  
   495  	result, err = client.GetSettingsResponder(resp)
   496  	if err != nil {
   497  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "GetSettings", resp, "Failure responding to request")
   498  		return
   499  	}
   500  
   501  	return
   502  }
   503  
   504  // GetSettingsPreparer prepares the GetSettings request.
   505  func (client AppsClient) GetSettingsPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) {
   506  	urlParameters := map[string]interface{}{
   507  		"Endpoint": client.Endpoint,
   508  	}
   509  
   510  	pathParameters := map[string]interface{}{
   511  		"appId": autorest.Encode("path", appID),
   512  	}
   513  
   514  	preparer := autorest.CreatePreparer(
   515  		autorest.AsGet(),
   516  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   517  		autorest.WithPathParameters("/apps/{appId}/settings", pathParameters))
   518  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   519  }
   520  
   521  // GetSettingsSender sends the GetSettings request. The method will close the
   522  // http.Response Body if it receives an error.
   523  func (client AppsClient) GetSettingsSender(req *http.Request) (*http.Response, error) {
   524  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   525  }
   526  
   527  // GetSettingsResponder handles the response to the GetSettings request. The method always
   528  // closes the http.Response Body.
   529  func (client AppsClient) GetSettingsResponder(resp *http.Response) (result ApplicationSettings, err error) {
   530  	err = autorest.Respond(
   531  		resp,
   532  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   533  		autorest.ByUnmarshallingJSON(&result),
   534  		autorest.ByClosing())
   535  	result.Response = autorest.Response{Response: resp}
   536  	return
   537  }
   538  
   539  // Import imports an application to LUIS, the application's structure is included in the request body.
   540  // Parameters:
   541  // luisApp - a LUIS application structure.
   542  // appName - the application name to create. If not specified, the application name will be read from the
   543  // imported object. If the application name already exists, an error is returned.
   544  func (client AppsClient) Import(ctx context.Context, luisApp LuisApp, appName string) (result UUID, err error) {
   545  	if tracing.IsEnabled() {
   546  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Import")
   547  		defer func() {
   548  			sc := -1
   549  			if result.Response.Response != nil {
   550  				sc = result.Response.Response.StatusCode
   551  			}
   552  			tracing.EndSpan(ctx, sc, err)
   553  		}()
   554  	}
   555  	req, err := client.ImportPreparer(ctx, luisApp, appName)
   556  	if err != nil {
   557  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Import", nil, "Failure preparing request")
   558  		return
   559  	}
   560  
   561  	resp, err := client.ImportSender(req)
   562  	if err != nil {
   563  		result.Response = autorest.Response{Response: resp}
   564  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Import", resp, "Failure sending request")
   565  		return
   566  	}
   567  
   568  	result, err = client.ImportResponder(resp)
   569  	if err != nil {
   570  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Import", resp, "Failure responding to request")
   571  		return
   572  	}
   573  
   574  	return
   575  }
   576  
   577  // ImportPreparer prepares the Import request.
   578  func (client AppsClient) ImportPreparer(ctx context.Context, luisApp LuisApp, appName string) (*http.Request, error) {
   579  	urlParameters := map[string]interface{}{
   580  		"Endpoint": client.Endpoint,
   581  	}
   582  
   583  	queryParameters := map[string]interface{}{}
   584  	if len(appName) > 0 {
   585  		queryParameters["appName"] = autorest.Encode("query", appName)
   586  	}
   587  
   588  	preparer := autorest.CreatePreparer(
   589  		autorest.AsContentType("application/json; charset=utf-8"),
   590  		autorest.AsPost(),
   591  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   592  		autorest.WithPath("/apps/import"),
   593  		autorest.WithJSON(luisApp),
   594  		autorest.WithQueryParameters(queryParameters))
   595  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   596  }
   597  
   598  // ImportSender sends the Import request. The method will close the
   599  // http.Response Body if it receives an error.
   600  func (client AppsClient) ImportSender(req *http.Request) (*http.Response, error) {
   601  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   602  }
   603  
   604  // ImportResponder handles the response to the Import request. The method always
   605  // closes the http.Response Body.
   606  func (client AppsClient) ImportResponder(resp *http.Response) (result UUID, err error) {
   607  	err = autorest.Respond(
   608  		resp,
   609  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   610  		autorest.ByUnmarshallingJSON(&result.Value),
   611  		autorest.ByClosing())
   612  	result.Response = autorest.Response{Response: resp}
   613  	return
   614  }
   615  
   616  // List lists all of the user's applications.
   617  // Parameters:
   618  // skip - the number of entries to skip. Default value is 0.
   619  // take - the number of entries to return. Maximum page size is 500. Default is 100.
   620  func (client AppsClient) List(ctx context.Context, skip *int32, take *int32) (result ListApplicationInfoResponse, err error) {
   621  	if tracing.IsEnabled() {
   622  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.List")
   623  		defer func() {
   624  			sc := -1
   625  			if result.Response.Response != nil {
   626  				sc = result.Response.Response.StatusCode
   627  			}
   628  			tracing.EndSpan(ctx, sc, err)
   629  		}()
   630  	}
   631  	if err := validation.Validate([]validation.Validation{
   632  		{TargetValue: skip,
   633  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   634  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
   635  		{TargetValue: take,
   636  			Constraints: []validation.Constraint{{Target: "take", Name: validation.Null, Rule: false,
   637  				Chain: []validation.Constraint{{Target: "take", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil},
   638  					{Target: "take", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
   639  				}}}}}); err != nil {
   640  		return result, validation.NewError("authoring.AppsClient", "List", err.Error())
   641  	}
   642  
   643  	req, err := client.ListPreparer(ctx, skip, take)
   644  	if err != nil {
   645  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "List", nil, "Failure preparing request")
   646  		return
   647  	}
   648  
   649  	resp, err := client.ListSender(req)
   650  	if err != nil {
   651  		result.Response = autorest.Response{Response: resp}
   652  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "List", resp, "Failure sending request")
   653  		return
   654  	}
   655  
   656  	result, err = client.ListResponder(resp)
   657  	if err != nil {
   658  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "List", resp, "Failure responding to request")
   659  		return
   660  	}
   661  
   662  	return
   663  }
   664  
   665  // ListPreparer prepares the List request.
   666  func (client AppsClient) ListPreparer(ctx context.Context, skip *int32, take *int32) (*http.Request, error) {
   667  	urlParameters := map[string]interface{}{
   668  		"Endpoint": client.Endpoint,
   669  	}
   670  
   671  	queryParameters := map[string]interface{}{}
   672  	if skip != nil {
   673  		queryParameters["skip"] = autorest.Encode("query", *skip)
   674  	} else {
   675  		queryParameters["skip"] = autorest.Encode("query", 0)
   676  	}
   677  	if take != nil {
   678  		queryParameters["take"] = autorest.Encode("query", *take)
   679  	} else {
   680  		queryParameters["take"] = autorest.Encode("query", 100)
   681  	}
   682  
   683  	preparer := autorest.CreatePreparer(
   684  		autorest.AsGet(),
   685  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   686  		autorest.WithPath("/apps/"),
   687  		autorest.WithQueryParameters(queryParameters))
   688  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   689  }
   690  
   691  // ListSender sends the List request. The method will close the
   692  // http.Response Body if it receives an error.
   693  func (client AppsClient) ListSender(req *http.Request) (*http.Response, error) {
   694  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   695  }
   696  
   697  // ListResponder handles the response to the List request. The method always
   698  // closes the http.Response Body.
   699  func (client AppsClient) ListResponder(resp *http.Response) (result ListApplicationInfoResponse, err error) {
   700  	err = autorest.Respond(
   701  		resp,
   702  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   703  		autorest.ByUnmarshallingJSON(&result.Value),
   704  		autorest.ByClosing())
   705  	result.Response = autorest.Response{Response: resp}
   706  	return
   707  }
   708  
   709  // ListAvailableCustomPrebuiltDomains gets all the available custom prebuilt domains for all cultures.
   710  func (client AppsClient) ListAvailableCustomPrebuiltDomains(ctx context.Context) (result ListPrebuiltDomain, err error) {
   711  	if tracing.IsEnabled() {
   712  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListAvailableCustomPrebuiltDomains")
   713  		defer func() {
   714  			sc := -1
   715  			if result.Response.Response != nil {
   716  				sc = result.Response.Response.StatusCode
   717  			}
   718  			tracing.EndSpan(ctx, sc, err)
   719  		}()
   720  	}
   721  	req, err := client.ListAvailableCustomPrebuiltDomainsPreparer(ctx)
   722  	if err != nil {
   723  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomains", nil, "Failure preparing request")
   724  		return
   725  	}
   726  
   727  	resp, err := client.ListAvailableCustomPrebuiltDomainsSender(req)
   728  	if err != nil {
   729  		result.Response = autorest.Response{Response: resp}
   730  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomains", resp, "Failure sending request")
   731  		return
   732  	}
   733  
   734  	result, err = client.ListAvailableCustomPrebuiltDomainsResponder(resp)
   735  	if err != nil {
   736  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomains", resp, "Failure responding to request")
   737  		return
   738  	}
   739  
   740  	return
   741  }
   742  
   743  // ListAvailableCustomPrebuiltDomainsPreparer prepares the ListAvailableCustomPrebuiltDomains request.
   744  func (client AppsClient) ListAvailableCustomPrebuiltDomainsPreparer(ctx context.Context) (*http.Request, error) {
   745  	urlParameters := map[string]interface{}{
   746  		"Endpoint": client.Endpoint,
   747  	}
   748  
   749  	preparer := autorest.CreatePreparer(
   750  		autorest.AsGet(),
   751  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   752  		autorest.WithPath("/apps/customprebuiltdomains"))
   753  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   754  }
   755  
   756  // ListAvailableCustomPrebuiltDomainsSender sends the ListAvailableCustomPrebuiltDomains request. The method will close the
   757  // http.Response Body if it receives an error.
   758  func (client AppsClient) ListAvailableCustomPrebuiltDomainsSender(req *http.Request) (*http.Response, error) {
   759  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   760  }
   761  
   762  // ListAvailableCustomPrebuiltDomainsResponder handles the response to the ListAvailableCustomPrebuiltDomains request. The method always
   763  // closes the http.Response Body.
   764  func (client AppsClient) ListAvailableCustomPrebuiltDomainsResponder(resp *http.Response) (result ListPrebuiltDomain, err error) {
   765  	err = autorest.Respond(
   766  		resp,
   767  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   768  		autorest.ByUnmarshallingJSON(&result.Value),
   769  		autorest.ByClosing())
   770  	result.Response = autorest.Response{Response: resp}
   771  	return
   772  }
   773  
   774  // ListAvailableCustomPrebuiltDomainsForCulture gets all the available prebuilt domains for a specific culture.
   775  // Parameters:
   776  // culture - culture.
   777  func (client AppsClient) ListAvailableCustomPrebuiltDomainsForCulture(ctx context.Context, culture string) (result ListPrebuiltDomain, err error) {
   778  	if tracing.IsEnabled() {
   779  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListAvailableCustomPrebuiltDomainsForCulture")
   780  		defer func() {
   781  			sc := -1
   782  			if result.Response.Response != nil {
   783  				sc = result.Response.Response.StatusCode
   784  			}
   785  			tracing.EndSpan(ctx, sc, err)
   786  		}()
   787  	}
   788  	req, err := client.ListAvailableCustomPrebuiltDomainsForCulturePreparer(ctx, culture)
   789  	if err != nil {
   790  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomainsForCulture", nil, "Failure preparing request")
   791  		return
   792  	}
   793  
   794  	resp, err := client.ListAvailableCustomPrebuiltDomainsForCultureSender(req)
   795  	if err != nil {
   796  		result.Response = autorest.Response{Response: resp}
   797  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomainsForCulture", resp, "Failure sending request")
   798  		return
   799  	}
   800  
   801  	result, err = client.ListAvailableCustomPrebuiltDomainsForCultureResponder(resp)
   802  	if err != nil {
   803  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListAvailableCustomPrebuiltDomainsForCulture", resp, "Failure responding to request")
   804  		return
   805  	}
   806  
   807  	return
   808  }
   809  
   810  // ListAvailableCustomPrebuiltDomainsForCulturePreparer prepares the ListAvailableCustomPrebuiltDomainsForCulture request.
   811  func (client AppsClient) ListAvailableCustomPrebuiltDomainsForCulturePreparer(ctx context.Context, culture string) (*http.Request, error) {
   812  	urlParameters := map[string]interface{}{
   813  		"Endpoint": client.Endpoint,
   814  	}
   815  
   816  	pathParameters := map[string]interface{}{
   817  		"culture": autorest.Encode("path", culture),
   818  	}
   819  
   820  	preparer := autorest.CreatePreparer(
   821  		autorest.AsGet(),
   822  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   823  		autorest.WithPathParameters("/apps/customprebuiltdomains/{culture}", pathParameters))
   824  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   825  }
   826  
   827  // ListAvailableCustomPrebuiltDomainsForCultureSender sends the ListAvailableCustomPrebuiltDomainsForCulture request. The method will close the
   828  // http.Response Body if it receives an error.
   829  func (client AppsClient) ListAvailableCustomPrebuiltDomainsForCultureSender(req *http.Request) (*http.Response, error) {
   830  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   831  }
   832  
   833  // ListAvailableCustomPrebuiltDomainsForCultureResponder handles the response to the ListAvailableCustomPrebuiltDomainsForCulture request. The method always
   834  // closes the http.Response Body.
   835  func (client AppsClient) ListAvailableCustomPrebuiltDomainsForCultureResponder(resp *http.Response) (result ListPrebuiltDomain, err error) {
   836  	err = autorest.Respond(
   837  		resp,
   838  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   839  		autorest.ByUnmarshallingJSON(&result.Value),
   840  		autorest.ByClosing())
   841  	result.Response = autorest.Response{Response: resp}
   842  	return
   843  }
   844  
   845  // ListCortanaEndpoints gets the endpoint URLs for the prebuilt Cortana applications.
   846  func (client AppsClient) ListCortanaEndpoints(ctx context.Context) (result PersonalAssistantsResponse, err error) {
   847  	if tracing.IsEnabled() {
   848  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListCortanaEndpoints")
   849  		defer func() {
   850  			sc := -1
   851  			if result.Response.Response != nil {
   852  				sc = result.Response.Response.StatusCode
   853  			}
   854  			tracing.EndSpan(ctx, sc, err)
   855  		}()
   856  	}
   857  	req, err := client.ListCortanaEndpointsPreparer(ctx)
   858  	if err != nil {
   859  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListCortanaEndpoints", nil, "Failure preparing request")
   860  		return
   861  	}
   862  
   863  	resp, err := client.ListCortanaEndpointsSender(req)
   864  	if err != nil {
   865  		result.Response = autorest.Response{Response: resp}
   866  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListCortanaEndpoints", resp, "Failure sending request")
   867  		return
   868  	}
   869  
   870  	result, err = client.ListCortanaEndpointsResponder(resp)
   871  	if err != nil {
   872  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListCortanaEndpoints", resp, "Failure responding to request")
   873  		return
   874  	}
   875  
   876  	return
   877  }
   878  
   879  // ListCortanaEndpointsPreparer prepares the ListCortanaEndpoints request.
   880  func (client AppsClient) ListCortanaEndpointsPreparer(ctx context.Context) (*http.Request, error) {
   881  	urlParameters := map[string]interface{}{
   882  		"Endpoint": client.Endpoint,
   883  	}
   884  
   885  	preparer := autorest.CreatePreparer(
   886  		autorest.AsGet(),
   887  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   888  		autorest.WithPath("/apps/assistants"))
   889  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   890  }
   891  
   892  // ListCortanaEndpointsSender sends the ListCortanaEndpoints request. The method will close the
   893  // http.Response Body if it receives an error.
   894  func (client AppsClient) ListCortanaEndpointsSender(req *http.Request) (*http.Response, error) {
   895  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   896  }
   897  
   898  // ListCortanaEndpointsResponder handles the response to the ListCortanaEndpoints request. The method always
   899  // closes the http.Response Body.
   900  func (client AppsClient) ListCortanaEndpointsResponder(resp *http.Response) (result PersonalAssistantsResponse, err error) {
   901  	err = autorest.Respond(
   902  		resp,
   903  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   904  		autorest.ByUnmarshallingJSON(&result),
   905  		autorest.ByClosing())
   906  	result.Response = autorest.Response{Response: resp}
   907  	return
   908  }
   909  
   910  // ListDomains gets the available application domains.
   911  func (client AppsClient) ListDomains(ctx context.Context) (result ListString, err error) {
   912  	if tracing.IsEnabled() {
   913  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListDomains")
   914  		defer func() {
   915  			sc := -1
   916  			if result.Response.Response != nil {
   917  				sc = result.Response.Response.StatusCode
   918  			}
   919  			tracing.EndSpan(ctx, sc, err)
   920  		}()
   921  	}
   922  	req, err := client.ListDomainsPreparer(ctx)
   923  	if err != nil {
   924  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListDomains", nil, "Failure preparing request")
   925  		return
   926  	}
   927  
   928  	resp, err := client.ListDomainsSender(req)
   929  	if err != nil {
   930  		result.Response = autorest.Response{Response: resp}
   931  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListDomains", resp, "Failure sending request")
   932  		return
   933  	}
   934  
   935  	result, err = client.ListDomainsResponder(resp)
   936  	if err != nil {
   937  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListDomains", resp, "Failure responding to request")
   938  		return
   939  	}
   940  
   941  	return
   942  }
   943  
   944  // ListDomainsPreparer prepares the ListDomains request.
   945  func (client AppsClient) ListDomainsPreparer(ctx context.Context) (*http.Request, error) {
   946  	urlParameters := map[string]interface{}{
   947  		"Endpoint": client.Endpoint,
   948  	}
   949  
   950  	preparer := autorest.CreatePreparer(
   951  		autorest.AsGet(),
   952  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   953  		autorest.WithPath("/apps/domains"))
   954  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   955  }
   956  
   957  // ListDomainsSender sends the ListDomains request. The method will close the
   958  // http.Response Body if it receives an error.
   959  func (client AppsClient) ListDomainsSender(req *http.Request) (*http.Response, error) {
   960  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   961  }
   962  
   963  // ListDomainsResponder handles the response to the ListDomains request. The method always
   964  // closes the http.Response Body.
   965  func (client AppsClient) ListDomainsResponder(resp *http.Response) (result ListString, err error) {
   966  	err = autorest.Respond(
   967  		resp,
   968  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   969  		autorest.ByUnmarshallingJSON(&result.Value),
   970  		autorest.ByClosing())
   971  	result.Response = autorest.Response{Response: resp}
   972  	return
   973  }
   974  
   975  // ListEndpoints returns the available endpoint deployment regions and URLs.
   976  // Parameters:
   977  // appID - the application ID.
   978  func (client AppsClient) ListEndpoints(ctx context.Context, appID uuid.UUID) (result SetString, err error) {
   979  	if tracing.IsEnabled() {
   980  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListEndpoints")
   981  		defer func() {
   982  			sc := -1
   983  			if result.Response.Response != nil {
   984  				sc = result.Response.Response.StatusCode
   985  			}
   986  			tracing.EndSpan(ctx, sc, err)
   987  		}()
   988  	}
   989  	req, err := client.ListEndpointsPreparer(ctx, appID)
   990  	if err != nil {
   991  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListEndpoints", nil, "Failure preparing request")
   992  		return
   993  	}
   994  
   995  	resp, err := client.ListEndpointsSender(req)
   996  	if err != nil {
   997  		result.Response = autorest.Response{Response: resp}
   998  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListEndpoints", resp, "Failure sending request")
   999  		return
  1000  	}
  1001  
  1002  	result, err = client.ListEndpointsResponder(resp)
  1003  	if err != nil {
  1004  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListEndpoints", resp, "Failure responding to request")
  1005  		return
  1006  	}
  1007  
  1008  	return
  1009  }
  1010  
  1011  // ListEndpointsPreparer prepares the ListEndpoints request.
  1012  func (client AppsClient) ListEndpointsPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) {
  1013  	urlParameters := map[string]interface{}{
  1014  		"Endpoint": client.Endpoint,
  1015  	}
  1016  
  1017  	pathParameters := map[string]interface{}{
  1018  		"appId": autorest.Encode("path", appID),
  1019  	}
  1020  
  1021  	preparer := autorest.CreatePreparer(
  1022  		autorest.AsGet(),
  1023  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1024  		autorest.WithPathParameters("/apps/{appId}/endpoints", pathParameters))
  1025  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1026  }
  1027  
  1028  // ListEndpointsSender sends the ListEndpoints request. The method will close the
  1029  // http.Response Body if it receives an error.
  1030  func (client AppsClient) ListEndpointsSender(req *http.Request) (*http.Response, error) {
  1031  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1032  }
  1033  
  1034  // ListEndpointsResponder handles the response to the ListEndpoints request. The method always
  1035  // closes the http.Response Body.
  1036  func (client AppsClient) ListEndpointsResponder(resp *http.Response) (result SetString, err error) {
  1037  	err = autorest.Respond(
  1038  		resp,
  1039  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1040  		autorest.ByUnmarshallingJSON(&result.Value),
  1041  		autorest.ByClosing())
  1042  	result.Response = autorest.Response{Response: resp}
  1043  	return
  1044  }
  1045  
  1046  // ListSupportedCultures gets a list of supported cultures. Cultures are equivalent to the written language and locale.
  1047  // For example,"en-us" represents the U.S. variation of English.
  1048  func (client AppsClient) ListSupportedCultures(ctx context.Context) (result ListAvailableCulture, err error) {
  1049  	if tracing.IsEnabled() {
  1050  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListSupportedCultures")
  1051  		defer func() {
  1052  			sc := -1
  1053  			if result.Response.Response != nil {
  1054  				sc = result.Response.Response.StatusCode
  1055  			}
  1056  			tracing.EndSpan(ctx, sc, err)
  1057  		}()
  1058  	}
  1059  	req, err := client.ListSupportedCulturesPreparer(ctx)
  1060  	if err != nil {
  1061  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListSupportedCultures", nil, "Failure preparing request")
  1062  		return
  1063  	}
  1064  
  1065  	resp, err := client.ListSupportedCulturesSender(req)
  1066  	if err != nil {
  1067  		result.Response = autorest.Response{Response: resp}
  1068  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListSupportedCultures", resp, "Failure sending request")
  1069  		return
  1070  	}
  1071  
  1072  	result, err = client.ListSupportedCulturesResponder(resp)
  1073  	if err != nil {
  1074  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListSupportedCultures", resp, "Failure responding to request")
  1075  		return
  1076  	}
  1077  
  1078  	return
  1079  }
  1080  
  1081  // ListSupportedCulturesPreparer prepares the ListSupportedCultures request.
  1082  func (client AppsClient) ListSupportedCulturesPreparer(ctx context.Context) (*http.Request, error) {
  1083  	urlParameters := map[string]interface{}{
  1084  		"Endpoint": client.Endpoint,
  1085  	}
  1086  
  1087  	preparer := autorest.CreatePreparer(
  1088  		autorest.AsGet(),
  1089  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1090  		autorest.WithPath("/apps/cultures"))
  1091  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1092  }
  1093  
  1094  // ListSupportedCulturesSender sends the ListSupportedCultures request. The method will close the
  1095  // http.Response Body if it receives an error.
  1096  func (client AppsClient) ListSupportedCulturesSender(req *http.Request) (*http.Response, error) {
  1097  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1098  }
  1099  
  1100  // ListSupportedCulturesResponder handles the response to the ListSupportedCultures request. The method always
  1101  // closes the http.Response Body.
  1102  func (client AppsClient) ListSupportedCulturesResponder(resp *http.Response) (result ListAvailableCulture, err error) {
  1103  	err = autorest.Respond(
  1104  		resp,
  1105  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1106  		autorest.ByUnmarshallingJSON(&result.Value),
  1107  		autorest.ByClosing())
  1108  	result.Response = autorest.Response{Response: resp}
  1109  	return
  1110  }
  1111  
  1112  // ListUsageScenarios gets the application available usage scenarios.
  1113  func (client AppsClient) ListUsageScenarios(ctx context.Context) (result ListString, err error) {
  1114  	if tracing.IsEnabled() {
  1115  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.ListUsageScenarios")
  1116  		defer func() {
  1117  			sc := -1
  1118  			if result.Response.Response != nil {
  1119  				sc = result.Response.Response.StatusCode
  1120  			}
  1121  			tracing.EndSpan(ctx, sc, err)
  1122  		}()
  1123  	}
  1124  	req, err := client.ListUsageScenariosPreparer(ctx)
  1125  	if err != nil {
  1126  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListUsageScenarios", nil, "Failure preparing request")
  1127  		return
  1128  	}
  1129  
  1130  	resp, err := client.ListUsageScenariosSender(req)
  1131  	if err != nil {
  1132  		result.Response = autorest.Response{Response: resp}
  1133  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListUsageScenarios", resp, "Failure sending request")
  1134  		return
  1135  	}
  1136  
  1137  	result, err = client.ListUsageScenariosResponder(resp)
  1138  	if err != nil {
  1139  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "ListUsageScenarios", resp, "Failure responding to request")
  1140  		return
  1141  	}
  1142  
  1143  	return
  1144  }
  1145  
  1146  // ListUsageScenariosPreparer prepares the ListUsageScenarios request.
  1147  func (client AppsClient) ListUsageScenariosPreparer(ctx context.Context) (*http.Request, error) {
  1148  	urlParameters := map[string]interface{}{
  1149  		"Endpoint": client.Endpoint,
  1150  	}
  1151  
  1152  	preparer := autorest.CreatePreparer(
  1153  		autorest.AsGet(),
  1154  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1155  		autorest.WithPath("/apps/usagescenarios"))
  1156  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1157  }
  1158  
  1159  // ListUsageScenariosSender sends the ListUsageScenarios request. The method will close the
  1160  // http.Response Body if it receives an error.
  1161  func (client AppsClient) ListUsageScenariosSender(req *http.Request) (*http.Response, error) {
  1162  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1163  }
  1164  
  1165  // ListUsageScenariosResponder handles the response to the ListUsageScenarios request. The method always
  1166  // closes the http.Response Body.
  1167  func (client AppsClient) ListUsageScenariosResponder(resp *http.Response) (result ListString, err error) {
  1168  	err = autorest.Respond(
  1169  		resp,
  1170  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1171  		autorest.ByUnmarshallingJSON(&result.Value),
  1172  		autorest.ByClosing())
  1173  	result.Response = autorest.Response{Response: resp}
  1174  	return
  1175  }
  1176  
  1177  // PackagePublishedApplicationAsGzip packages a published LUIS application as a GZip file to be used in the LUIS
  1178  // container.
  1179  // Parameters:
  1180  // appID - the application ID.
  1181  // slotName - the publishing slot name.
  1182  func (client AppsClient) PackagePublishedApplicationAsGzip(ctx context.Context, appID uuid.UUID, slotName string) (result ReadCloser, err error) {
  1183  	if tracing.IsEnabled() {
  1184  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.PackagePublishedApplicationAsGzip")
  1185  		defer func() {
  1186  			sc := -1
  1187  			if result.Response.Response != nil {
  1188  				sc = result.Response.Response.StatusCode
  1189  			}
  1190  			tracing.EndSpan(ctx, sc, err)
  1191  		}()
  1192  	}
  1193  	req, err := client.PackagePublishedApplicationAsGzipPreparer(ctx, appID, slotName)
  1194  	if err != nil {
  1195  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", nil, "Failure preparing request")
  1196  		return
  1197  	}
  1198  
  1199  	resp, err := client.PackagePublishedApplicationAsGzipSender(req)
  1200  	if err != nil {
  1201  		result.Response = autorest.Response{Response: resp}
  1202  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", resp, "Failure sending request")
  1203  		return
  1204  	}
  1205  
  1206  	result, err = client.PackagePublishedApplicationAsGzipResponder(resp)
  1207  	if err != nil {
  1208  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", resp, "Failure responding to request")
  1209  		return
  1210  	}
  1211  
  1212  	return
  1213  }
  1214  
  1215  // PackagePublishedApplicationAsGzipPreparer prepares the PackagePublishedApplicationAsGzip request.
  1216  func (client AppsClient) PackagePublishedApplicationAsGzipPreparer(ctx context.Context, appID uuid.UUID, slotName string) (*http.Request, error) {
  1217  	urlParameters := map[string]interface{}{
  1218  		"Endpoint": client.Endpoint,
  1219  	}
  1220  
  1221  	pathParameters := map[string]interface{}{
  1222  		"appId":    autorest.Encode("path", appID),
  1223  		"slotName": autorest.Encode("path", slotName),
  1224  	}
  1225  
  1226  	preparer := autorest.CreatePreparer(
  1227  		autorest.AsGet(),
  1228  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1229  		autorest.WithPathParameters("/package/{appId}/slot/{slotName}/gzip", pathParameters))
  1230  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1231  }
  1232  
  1233  // PackagePublishedApplicationAsGzipSender sends the PackagePublishedApplicationAsGzip request. The method will close the
  1234  // http.Response Body if it receives an error.
  1235  func (client AppsClient) PackagePublishedApplicationAsGzipSender(req *http.Request) (*http.Response, error) {
  1236  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1237  }
  1238  
  1239  // PackagePublishedApplicationAsGzipResponder handles the response to the PackagePublishedApplicationAsGzip request. The method always
  1240  // closes the http.Response Body.
  1241  func (client AppsClient) PackagePublishedApplicationAsGzipResponder(resp *http.Response) (result ReadCloser, err error) {
  1242  	result.Value = &resp.Body
  1243  	err = autorest.Respond(
  1244  		resp,
  1245  		azure.WithErrorUnlessStatusCode(http.StatusOK))
  1246  	result.Response = autorest.Response{Response: resp}
  1247  	return
  1248  }
  1249  
  1250  // PackageTrainedApplicationAsGzip packages trained LUIS application as GZip file to be used in the LUIS container.
  1251  // Parameters:
  1252  // appID - the application ID.
  1253  // versionID - the version ID.
  1254  func (client AppsClient) PackageTrainedApplicationAsGzip(ctx context.Context, appID uuid.UUID, versionID string) (result ReadCloser, err error) {
  1255  	if tracing.IsEnabled() {
  1256  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.PackageTrainedApplicationAsGzip")
  1257  		defer func() {
  1258  			sc := -1
  1259  			if result.Response.Response != nil {
  1260  				sc = result.Response.Response.StatusCode
  1261  			}
  1262  			tracing.EndSpan(ctx, sc, err)
  1263  		}()
  1264  	}
  1265  	req, err := client.PackageTrainedApplicationAsGzipPreparer(ctx, appID, versionID)
  1266  	if err != nil {
  1267  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", nil, "Failure preparing request")
  1268  		return
  1269  	}
  1270  
  1271  	resp, err := client.PackageTrainedApplicationAsGzipSender(req)
  1272  	if err != nil {
  1273  		result.Response = autorest.Response{Response: resp}
  1274  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", resp, "Failure sending request")
  1275  		return
  1276  	}
  1277  
  1278  	result, err = client.PackageTrainedApplicationAsGzipResponder(resp)
  1279  	if err != nil {
  1280  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", resp, "Failure responding to request")
  1281  		return
  1282  	}
  1283  
  1284  	return
  1285  }
  1286  
  1287  // PackageTrainedApplicationAsGzipPreparer prepares the PackageTrainedApplicationAsGzip request.
  1288  func (client AppsClient) PackageTrainedApplicationAsGzipPreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) {
  1289  	urlParameters := map[string]interface{}{
  1290  		"Endpoint": client.Endpoint,
  1291  	}
  1292  
  1293  	pathParameters := map[string]interface{}{
  1294  		"appId":     autorest.Encode("path", appID),
  1295  		"versionId": autorest.Encode("path", versionID),
  1296  	}
  1297  
  1298  	preparer := autorest.CreatePreparer(
  1299  		autorest.AsGet(),
  1300  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1301  		autorest.WithPathParameters("/package/{appId}/versions/{versionId}/gzip", pathParameters))
  1302  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1303  }
  1304  
  1305  // PackageTrainedApplicationAsGzipSender sends the PackageTrainedApplicationAsGzip request. The method will close the
  1306  // http.Response Body if it receives an error.
  1307  func (client AppsClient) PackageTrainedApplicationAsGzipSender(req *http.Request) (*http.Response, error) {
  1308  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1309  }
  1310  
  1311  // PackageTrainedApplicationAsGzipResponder handles the response to the PackageTrainedApplicationAsGzip request. The method always
  1312  // closes the http.Response Body.
  1313  func (client AppsClient) PackageTrainedApplicationAsGzipResponder(resp *http.Response) (result ReadCloser, err error) {
  1314  	result.Value = &resp.Body
  1315  	err = autorest.Respond(
  1316  		resp,
  1317  		azure.WithErrorUnlessStatusCode(http.StatusOK))
  1318  	result.Response = autorest.Response{Response: resp}
  1319  	return
  1320  }
  1321  
  1322  // Publish publishes a specific version of the application.
  1323  // Parameters:
  1324  // appID - the application ID.
  1325  // applicationPublishObject - the application publish object. The region is the target region that the
  1326  // application is published to.
  1327  func (client AppsClient) Publish(ctx context.Context, appID uuid.UUID, applicationPublishObject ApplicationPublishObject) (result ProductionOrStagingEndpointInfo, err error) {
  1328  	if tracing.IsEnabled() {
  1329  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Publish")
  1330  		defer func() {
  1331  			sc := -1
  1332  			if result.Response.Response != nil {
  1333  				sc = result.Response.Response.StatusCode
  1334  			}
  1335  			tracing.EndSpan(ctx, sc, err)
  1336  		}()
  1337  	}
  1338  	req, err := client.PublishPreparer(ctx, appID, applicationPublishObject)
  1339  	if err != nil {
  1340  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Publish", nil, "Failure preparing request")
  1341  		return
  1342  	}
  1343  
  1344  	resp, err := client.PublishSender(req)
  1345  	if err != nil {
  1346  		result.Response = autorest.Response{Response: resp}
  1347  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Publish", resp, "Failure sending request")
  1348  		return
  1349  	}
  1350  
  1351  	result, err = client.PublishResponder(resp)
  1352  	if err != nil {
  1353  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Publish", resp, "Failure responding to request")
  1354  		return
  1355  	}
  1356  
  1357  	return
  1358  }
  1359  
  1360  // PublishPreparer prepares the Publish request.
  1361  func (client AppsClient) PublishPreparer(ctx context.Context, appID uuid.UUID, applicationPublishObject ApplicationPublishObject) (*http.Request, error) {
  1362  	urlParameters := map[string]interface{}{
  1363  		"Endpoint": client.Endpoint,
  1364  	}
  1365  
  1366  	pathParameters := map[string]interface{}{
  1367  		"appId": autorest.Encode("path", appID),
  1368  	}
  1369  
  1370  	preparer := autorest.CreatePreparer(
  1371  		autorest.AsContentType("application/json; charset=utf-8"),
  1372  		autorest.AsPost(),
  1373  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1374  		autorest.WithPathParameters("/apps/{appId}/publish", pathParameters),
  1375  		autorest.WithJSON(applicationPublishObject))
  1376  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1377  }
  1378  
  1379  // PublishSender sends the Publish request. The method will close the
  1380  // http.Response Body if it receives an error.
  1381  func (client AppsClient) PublishSender(req *http.Request) (*http.Response, error) {
  1382  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1383  }
  1384  
  1385  // PublishResponder handles the response to the Publish request. The method always
  1386  // closes the http.Response Body.
  1387  func (client AppsClient) PublishResponder(resp *http.Response) (result ProductionOrStagingEndpointInfo, err error) {
  1388  	err = autorest.Respond(
  1389  		resp,
  1390  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusMultiStatus),
  1391  		autorest.ByUnmarshallingJSON(&result),
  1392  		autorest.ByClosing())
  1393  	result.Response = autorest.Response{Response: resp}
  1394  	return
  1395  }
  1396  
  1397  // Update updates the name or description of the application.
  1398  // Parameters:
  1399  // appID - the application ID.
  1400  // applicationUpdateObject - a model containing Name and Description of the application.
  1401  func (client AppsClient) Update(ctx context.Context, appID uuid.UUID, applicationUpdateObject ApplicationUpdateObject) (result OperationStatus, err error) {
  1402  	if tracing.IsEnabled() {
  1403  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Update")
  1404  		defer func() {
  1405  			sc := -1
  1406  			if result.Response.Response != nil {
  1407  				sc = result.Response.Response.StatusCode
  1408  			}
  1409  			tracing.EndSpan(ctx, sc, err)
  1410  		}()
  1411  	}
  1412  	req, err := client.UpdatePreparer(ctx, appID, applicationUpdateObject)
  1413  	if err != nil {
  1414  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Update", nil, "Failure preparing request")
  1415  		return
  1416  	}
  1417  
  1418  	resp, err := client.UpdateSender(req)
  1419  	if err != nil {
  1420  		result.Response = autorest.Response{Response: resp}
  1421  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Update", resp, "Failure sending request")
  1422  		return
  1423  	}
  1424  
  1425  	result, err = client.UpdateResponder(resp)
  1426  	if err != nil {
  1427  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Update", resp, "Failure responding to request")
  1428  		return
  1429  	}
  1430  
  1431  	return
  1432  }
  1433  
  1434  // UpdatePreparer prepares the Update request.
  1435  func (client AppsClient) UpdatePreparer(ctx context.Context, appID uuid.UUID, applicationUpdateObject ApplicationUpdateObject) (*http.Request, error) {
  1436  	urlParameters := map[string]interface{}{
  1437  		"Endpoint": client.Endpoint,
  1438  	}
  1439  
  1440  	pathParameters := map[string]interface{}{
  1441  		"appId": autorest.Encode("path", appID),
  1442  	}
  1443  
  1444  	preparer := autorest.CreatePreparer(
  1445  		autorest.AsContentType("application/json; charset=utf-8"),
  1446  		autorest.AsPut(),
  1447  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1448  		autorest.WithPathParameters("/apps/{appId}", pathParameters),
  1449  		autorest.WithJSON(applicationUpdateObject))
  1450  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1451  }
  1452  
  1453  // UpdateSender sends the Update request. The method will close the
  1454  // http.Response Body if it receives an error.
  1455  func (client AppsClient) UpdateSender(req *http.Request) (*http.Response, error) {
  1456  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1457  }
  1458  
  1459  // UpdateResponder handles the response to the Update request. The method always
  1460  // closes the http.Response Body.
  1461  func (client AppsClient) UpdateResponder(resp *http.Response) (result OperationStatus, err error) {
  1462  	err = autorest.Respond(
  1463  		resp,
  1464  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1465  		autorest.ByUnmarshallingJSON(&result),
  1466  		autorest.ByClosing())
  1467  	result.Response = autorest.Response{Response: resp}
  1468  	return
  1469  }
  1470  
  1471  // UpdatePublishSettings updates the application publish settings including 'UseAllTrainingData'.
  1472  // Parameters:
  1473  // appID - the application ID.
  1474  // publishSettingUpdateObject - an object containing the new publish application settings.
  1475  func (client AppsClient) UpdatePublishSettings(ctx context.Context, appID uuid.UUID, publishSettingUpdateObject PublishSettingUpdateObject) (result OperationStatus, err error) {
  1476  	if tracing.IsEnabled() {
  1477  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.UpdatePublishSettings")
  1478  		defer func() {
  1479  			sc := -1
  1480  			if result.Response.Response != nil {
  1481  				sc = result.Response.Response.StatusCode
  1482  			}
  1483  			tracing.EndSpan(ctx, sc, err)
  1484  		}()
  1485  	}
  1486  	req, err := client.UpdatePublishSettingsPreparer(ctx, appID, publishSettingUpdateObject)
  1487  	if err != nil {
  1488  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdatePublishSettings", nil, "Failure preparing request")
  1489  		return
  1490  	}
  1491  
  1492  	resp, err := client.UpdatePublishSettingsSender(req)
  1493  	if err != nil {
  1494  		result.Response = autorest.Response{Response: resp}
  1495  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdatePublishSettings", resp, "Failure sending request")
  1496  		return
  1497  	}
  1498  
  1499  	result, err = client.UpdatePublishSettingsResponder(resp)
  1500  	if err != nil {
  1501  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdatePublishSettings", resp, "Failure responding to request")
  1502  		return
  1503  	}
  1504  
  1505  	return
  1506  }
  1507  
  1508  // UpdatePublishSettingsPreparer prepares the UpdatePublishSettings request.
  1509  func (client AppsClient) UpdatePublishSettingsPreparer(ctx context.Context, appID uuid.UUID, publishSettingUpdateObject PublishSettingUpdateObject) (*http.Request, error) {
  1510  	urlParameters := map[string]interface{}{
  1511  		"Endpoint": client.Endpoint,
  1512  	}
  1513  
  1514  	pathParameters := map[string]interface{}{
  1515  		"appId": autorest.Encode("path", appID),
  1516  	}
  1517  
  1518  	preparer := autorest.CreatePreparer(
  1519  		autorest.AsContentType("application/json; charset=utf-8"),
  1520  		autorest.AsPut(),
  1521  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1522  		autorest.WithPathParameters("/apps/{appId}/publishsettings", pathParameters),
  1523  		autorest.WithJSON(publishSettingUpdateObject))
  1524  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1525  }
  1526  
  1527  // UpdatePublishSettingsSender sends the UpdatePublishSettings request. The method will close the
  1528  // http.Response Body if it receives an error.
  1529  func (client AppsClient) UpdatePublishSettingsSender(req *http.Request) (*http.Response, error) {
  1530  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1531  }
  1532  
  1533  // UpdatePublishSettingsResponder handles the response to the UpdatePublishSettings request. The method always
  1534  // closes the http.Response Body.
  1535  func (client AppsClient) UpdatePublishSettingsResponder(resp *http.Response) (result OperationStatus, err error) {
  1536  	err = autorest.Respond(
  1537  		resp,
  1538  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1539  		autorest.ByUnmarshallingJSON(&result),
  1540  		autorest.ByClosing())
  1541  	result.Response = autorest.Response{Response: resp}
  1542  	return
  1543  }
  1544  
  1545  // UpdateSettings updates the application settings including 'UseAllTrainingData'.
  1546  // Parameters:
  1547  // appID - the application ID.
  1548  // applicationSettingUpdateObject - an object containing the new application settings.
  1549  func (client AppsClient) UpdateSettings(ctx context.Context, appID uuid.UUID, applicationSettingUpdateObject ApplicationSettingUpdateObject) (result OperationStatus, err error) {
  1550  	if tracing.IsEnabled() {
  1551  		ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.UpdateSettings")
  1552  		defer func() {
  1553  			sc := -1
  1554  			if result.Response.Response != nil {
  1555  				sc = result.Response.Response.StatusCode
  1556  			}
  1557  			tracing.EndSpan(ctx, sc, err)
  1558  		}()
  1559  	}
  1560  	req, err := client.UpdateSettingsPreparer(ctx, appID, applicationSettingUpdateObject)
  1561  	if err != nil {
  1562  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdateSettings", nil, "Failure preparing request")
  1563  		return
  1564  	}
  1565  
  1566  	resp, err := client.UpdateSettingsSender(req)
  1567  	if err != nil {
  1568  		result.Response = autorest.Response{Response: resp}
  1569  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdateSettings", resp, "Failure sending request")
  1570  		return
  1571  	}
  1572  
  1573  	result, err = client.UpdateSettingsResponder(resp)
  1574  	if err != nil {
  1575  		err = autorest.NewErrorWithError(err, "authoring.AppsClient", "UpdateSettings", resp, "Failure responding to request")
  1576  		return
  1577  	}
  1578  
  1579  	return
  1580  }
  1581  
  1582  // UpdateSettingsPreparer prepares the UpdateSettings request.
  1583  func (client AppsClient) UpdateSettingsPreparer(ctx context.Context, appID uuid.UUID, applicationSettingUpdateObject ApplicationSettingUpdateObject) (*http.Request, error) {
  1584  	urlParameters := map[string]interface{}{
  1585  		"Endpoint": client.Endpoint,
  1586  	}
  1587  
  1588  	pathParameters := map[string]interface{}{
  1589  		"appId": autorest.Encode("path", appID),
  1590  	}
  1591  
  1592  	preparer := autorest.CreatePreparer(
  1593  		autorest.AsContentType("application/json; charset=utf-8"),
  1594  		autorest.AsPut(),
  1595  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
  1596  		autorest.WithPathParameters("/apps/{appId}/settings", pathParameters),
  1597  		autorest.WithJSON(applicationSettingUpdateObject))
  1598  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
  1599  }
  1600  
  1601  // UpdateSettingsSender sends the UpdateSettings request. The method will close the
  1602  // http.Response Body if it receives an error.
  1603  func (client AppsClient) UpdateSettingsSender(req *http.Request) (*http.Response, error) {
  1604  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
  1605  }
  1606  
  1607  // UpdateSettingsResponder handles the response to the UpdateSettings request. The method always
  1608  // closes the http.Response Body.
  1609  func (client AppsClient) UpdateSettingsResponder(resp *http.Response) (result OperationStatus, err error) {
  1610  	err = autorest.Respond(
  1611  		resp,
  1612  		azure.WithErrorUnlessStatusCode(http.StatusOK),
  1613  		autorest.ByUnmarshallingJSON(&result),
  1614  		autorest.ByClosing())
  1615  	result.Response = autorest.Response{Response: resp}
  1616  	return
  1617  }
  1618  

View as plain text