...

Source file src/github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/authoring/features.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  // FeaturesClient is the client for the Features methods of the Authoring service.
    20  type FeaturesClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewFeaturesClient creates an instance of the FeaturesClient client.
    25  func NewFeaturesClient(endpoint string) FeaturesClient {
    26  	return FeaturesClient{New(endpoint)}
    27  }
    28  
    29  // AddPhraseList creates a new phraselist feature in a version of the application.
    30  // Parameters:
    31  // appID - the application ID.
    32  // versionID - the version ID.
    33  // phraselistCreateObject - a Phraselist object containing Name, comma-separated Phrases and the isExchangeable
    34  // boolean. Default value for isExchangeable is true.
    35  func (client FeaturesClient) AddPhraseList(ctx context.Context, appID uuid.UUID, versionID string, phraselistCreateObject PhraselistCreateObject) (result Int32, err error) {
    36  	if tracing.IsEnabled() {
    37  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.AddPhraseList")
    38  		defer func() {
    39  			sc := -1
    40  			if result.Response.Response != nil {
    41  				sc = result.Response.Response.StatusCode
    42  			}
    43  			tracing.EndSpan(ctx, sc, err)
    44  		}()
    45  	}
    46  	req, err := client.AddPhraseListPreparer(ctx, appID, versionID, phraselistCreateObject)
    47  	if err != nil {
    48  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "AddPhraseList", nil, "Failure preparing request")
    49  		return
    50  	}
    51  
    52  	resp, err := client.AddPhraseListSender(req)
    53  	if err != nil {
    54  		result.Response = autorest.Response{Response: resp}
    55  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "AddPhraseList", resp, "Failure sending request")
    56  		return
    57  	}
    58  
    59  	result, err = client.AddPhraseListResponder(resp)
    60  	if err != nil {
    61  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "AddPhraseList", resp, "Failure responding to request")
    62  		return
    63  	}
    64  
    65  	return
    66  }
    67  
    68  // AddPhraseListPreparer prepares the AddPhraseList request.
    69  func (client FeaturesClient) AddPhraseListPreparer(ctx context.Context, appID uuid.UUID, versionID string, phraselistCreateObject PhraselistCreateObject) (*http.Request, error) {
    70  	urlParameters := map[string]interface{}{
    71  		"Endpoint": client.Endpoint,
    72  	}
    73  
    74  	pathParameters := map[string]interface{}{
    75  		"appId":     autorest.Encode("path", appID),
    76  		"versionId": autorest.Encode("path", versionID),
    77  	}
    78  
    79  	preparer := autorest.CreatePreparer(
    80  		autorest.AsContentType("application/json; charset=utf-8"),
    81  		autorest.AsPost(),
    82  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
    83  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/phraselists", pathParameters),
    84  		autorest.WithJSON(phraselistCreateObject))
    85  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    86  }
    87  
    88  // AddPhraseListSender sends the AddPhraseList request. The method will close the
    89  // http.Response Body if it receives an error.
    90  func (client FeaturesClient) AddPhraseListSender(req *http.Request) (*http.Response, error) {
    91  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    92  }
    93  
    94  // AddPhraseListResponder handles the response to the AddPhraseList request. The method always
    95  // closes the http.Response Body.
    96  func (client FeaturesClient) AddPhraseListResponder(resp *http.Response) (result Int32, err error) {
    97  	err = autorest.Respond(
    98  		resp,
    99  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   100  		autorest.ByUnmarshallingJSON(&result.Value),
   101  		autorest.ByClosing())
   102  	result.Response = autorest.Response{Response: resp}
   103  	return
   104  }
   105  
   106  // DeletePhraseList deletes a phraselist feature from a version of the application.
   107  // Parameters:
   108  // appID - the application ID.
   109  // versionID - the version ID.
   110  // phraselistID - the ID of the feature to be deleted.
   111  func (client FeaturesClient) DeletePhraseList(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32) (result OperationStatus, err error) {
   112  	if tracing.IsEnabled() {
   113  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.DeletePhraseList")
   114  		defer func() {
   115  			sc := -1
   116  			if result.Response.Response != nil {
   117  				sc = result.Response.Response.StatusCode
   118  			}
   119  			tracing.EndSpan(ctx, sc, err)
   120  		}()
   121  	}
   122  	req, err := client.DeletePhraseListPreparer(ctx, appID, versionID, phraselistID)
   123  	if err != nil {
   124  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "DeletePhraseList", nil, "Failure preparing request")
   125  		return
   126  	}
   127  
   128  	resp, err := client.DeletePhraseListSender(req)
   129  	if err != nil {
   130  		result.Response = autorest.Response{Response: resp}
   131  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "DeletePhraseList", resp, "Failure sending request")
   132  		return
   133  	}
   134  
   135  	result, err = client.DeletePhraseListResponder(resp)
   136  	if err != nil {
   137  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "DeletePhraseList", resp, "Failure responding to request")
   138  		return
   139  	}
   140  
   141  	return
   142  }
   143  
   144  // DeletePhraseListPreparer prepares the DeletePhraseList request.
   145  func (client FeaturesClient) DeletePhraseListPreparer(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32) (*http.Request, error) {
   146  	urlParameters := map[string]interface{}{
   147  		"Endpoint": client.Endpoint,
   148  	}
   149  
   150  	pathParameters := map[string]interface{}{
   151  		"appId":        autorest.Encode("path", appID),
   152  		"phraselistId": autorest.Encode("path", phraselistID),
   153  		"versionId":    autorest.Encode("path", versionID),
   154  	}
   155  
   156  	preparer := autorest.CreatePreparer(
   157  		autorest.AsDelete(),
   158  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   159  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/phraselists/{phraselistId}", pathParameters))
   160  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   161  }
   162  
   163  // DeletePhraseListSender sends the DeletePhraseList request. The method will close the
   164  // http.Response Body if it receives an error.
   165  func (client FeaturesClient) DeletePhraseListSender(req *http.Request) (*http.Response, error) {
   166  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   167  }
   168  
   169  // DeletePhraseListResponder handles the response to the DeletePhraseList request. The method always
   170  // closes the http.Response Body.
   171  func (client FeaturesClient) DeletePhraseListResponder(resp *http.Response) (result OperationStatus, err error) {
   172  	err = autorest.Respond(
   173  		resp,
   174  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   175  		autorest.ByUnmarshallingJSON(&result),
   176  		autorest.ByClosing())
   177  	result.Response = autorest.Response{Response: resp}
   178  	return
   179  }
   180  
   181  // GetPhraseList gets phraselist feature info in a version of the application.
   182  // Parameters:
   183  // appID - the application ID.
   184  // versionID - the version ID.
   185  // phraselistID - the ID of the feature to be retrieved.
   186  func (client FeaturesClient) GetPhraseList(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32) (result PhraseListFeatureInfo, err error) {
   187  	if tracing.IsEnabled() {
   188  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.GetPhraseList")
   189  		defer func() {
   190  			sc := -1
   191  			if result.Response.Response != nil {
   192  				sc = result.Response.Response.StatusCode
   193  			}
   194  			tracing.EndSpan(ctx, sc, err)
   195  		}()
   196  	}
   197  	req, err := client.GetPhraseListPreparer(ctx, appID, versionID, phraselistID)
   198  	if err != nil {
   199  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "GetPhraseList", nil, "Failure preparing request")
   200  		return
   201  	}
   202  
   203  	resp, err := client.GetPhraseListSender(req)
   204  	if err != nil {
   205  		result.Response = autorest.Response{Response: resp}
   206  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "GetPhraseList", resp, "Failure sending request")
   207  		return
   208  	}
   209  
   210  	result, err = client.GetPhraseListResponder(resp)
   211  	if err != nil {
   212  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "GetPhraseList", resp, "Failure responding to request")
   213  		return
   214  	}
   215  
   216  	return
   217  }
   218  
   219  // GetPhraseListPreparer prepares the GetPhraseList request.
   220  func (client FeaturesClient) GetPhraseListPreparer(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32) (*http.Request, error) {
   221  	urlParameters := map[string]interface{}{
   222  		"Endpoint": client.Endpoint,
   223  	}
   224  
   225  	pathParameters := map[string]interface{}{
   226  		"appId":        autorest.Encode("path", appID),
   227  		"phraselistId": autorest.Encode("path", phraselistID),
   228  		"versionId":    autorest.Encode("path", versionID),
   229  	}
   230  
   231  	preparer := autorest.CreatePreparer(
   232  		autorest.AsGet(),
   233  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   234  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/phraselists/{phraselistId}", pathParameters))
   235  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   236  }
   237  
   238  // GetPhraseListSender sends the GetPhraseList request. The method will close the
   239  // http.Response Body if it receives an error.
   240  func (client FeaturesClient) GetPhraseListSender(req *http.Request) (*http.Response, error) {
   241  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   242  }
   243  
   244  // GetPhraseListResponder handles the response to the GetPhraseList request. The method always
   245  // closes the http.Response Body.
   246  func (client FeaturesClient) GetPhraseListResponder(resp *http.Response) (result PhraseListFeatureInfo, 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  // List gets all the extraction phraselist and pattern features in a version of the application.
   257  // Parameters:
   258  // appID - the application ID.
   259  // versionID - the version ID.
   260  // skip - the number of entries to skip. Default value is 0.
   261  // take - the number of entries to return. Maximum page size is 500. Default is 100.
   262  func (client FeaturesClient) List(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (result FeaturesResponseObject, err error) {
   263  	if tracing.IsEnabled() {
   264  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.List")
   265  		defer func() {
   266  			sc := -1
   267  			if result.Response.Response != nil {
   268  				sc = result.Response.Response.StatusCode
   269  			}
   270  			tracing.EndSpan(ctx, sc, err)
   271  		}()
   272  	}
   273  	if err := validation.Validate([]validation.Validation{
   274  		{TargetValue: skip,
   275  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   276  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
   277  		{TargetValue: take,
   278  			Constraints: []validation.Constraint{{Target: "take", Name: validation.Null, Rule: false,
   279  				Chain: []validation.Constraint{{Target: "take", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil},
   280  					{Target: "take", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
   281  				}}}}}); err != nil {
   282  		return result, validation.NewError("authoring.FeaturesClient", "List", err.Error())
   283  	}
   284  
   285  	req, err := client.ListPreparer(ctx, appID, versionID, skip, take)
   286  	if err != nil {
   287  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "List", nil, "Failure preparing request")
   288  		return
   289  	}
   290  
   291  	resp, err := client.ListSender(req)
   292  	if err != nil {
   293  		result.Response = autorest.Response{Response: resp}
   294  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "List", resp, "Failure sending request")
   295  		return
   296  	}
   297  
   298  	result, err = client.ListResponder(resp)
   299  	if err != nil {
   300  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "List", resp, "Failure responding to request")
   301  		return
   302  	}
   303  
   304  	return
   305  }
   306  
   307  // ListPreparer prepares the List request.
   308  func (client FeaturesClient) ListPreparer(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (*http.Request, error) {
   309  	urlParameters := map[string]interface{}{
   310  		"Endpoint": client.Endpoint,
   311  	}
   312  
   313  	pathParameters := map[string]interface{}{
   314  		"appId":     autorest.Encode("path", appID),
   315  		"versionId": autorest.Encode("path", versionID),
   316  	}
   317  
   318  	queryParameters := map[string]interface{}{}
   319  	if skip != nil {
   320  		queryParameters["skip"] = autorest.Encode("query", *skip)
   321  	} else {
   322  		queryParameters["skip"] = autorest.Encode("query", 0)
   323  	}
   324  	if take != nil {
   325  		queryParameters["take"] = autorest.Encode("query", *take)
   326  	} else {
   327  		queryParameters["take"] = autorest.Encode("query", 100)
   328  	}
   329  
   330  	preparer := autorest.CreatePreparer(
   331  		autorest.AsGet(),
   332  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   333  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/features", pathParameters),
   334  		autorest.WithQueryParameters(queryParameters))
   335  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   336  }
   337  
   338  // ListSender sends the List request. The method will close the
   339  // http.Response Body if it receives an error.
   340  func (client FeaturesClient) ListSender(req *http.Request) (*http.Response, error) {
   341  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   342  }
   343  
   344  // ListResponder handles the response to the List request. The method always
   345  // closes the http.Response Body.
   346  func (client FeaturesClient) ListResponder(resp *http.Response) (result FeaturesResponseObject, err error) {
   347  	err = autorest.Respond(
   348  		resp,
   349  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   350  		autorest.ByUnmarshallingJSON(&result),
   351  		autorest.ByClosing())
   352  	result.Response = autorest.Response{Response: resp}
   353  	return
   354  }
   355  
   356  // ListApplicationVersionPatternFeatures [DEPRECATED NOTICE: This operation will soon be removed] Gets all the pattern
   357  // features.
   358  // Parameters:
   359  // appID - the application ID.
   360  // versionID - the version ID.
   361  // skip - the number of entries to skip. Default value is 0.
   362  // take - the number of entries to return. Maximum page size is 500. Default is 100.
   363  func (client FeaturesClient) ListApplicationVersionPatternFeatures(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (result ListPatternFeatureInfo, err error) {
   364  	if tracing.IsEnabled() {
   365  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.ListApplicationVersionPatternFeatures")
   366  		defer func() {
   367  			sc := -1
   368  			if result.Response.Response != nil {
   369  				sc = result.Response.Response.StatusCode
   370  			}
   371  			tracing.EndSpan(ctx, sc, err)
   372  		}()
   373  	}
   374  	if err := validation.Validate([]validation.Validation{
   375  		{TargetValue: skip,
   376  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   377  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
   378  		{TargetValue: take,
   379  			Constraints: []validation.Constraint{{Target: "take", Name: validation.Null, Rule: false,
   380  				Chain: []validation.Constraint{{Target: "take", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil},
   381  					{Target: "take", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
   382  				}}}}}); err != nil {
   383  		return result, validation.NewError("authoring.FeaturesClient", "ListApplicationVersionPatternFeatures", err.Error())
   384  	}
   385  
   386  	req, err := client.ListApplicationVersionPatternFeaturesPreparer(ctx, appID, versionID, skip, take)
   387  	if err != nil {
   388  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListApplicationVersionPatternFeatures", nil, "Failure preparing request")
   389  		return
   390  	}
   391  
   392  	resp, err := client.ListApplicationVersionPatternFeaturesSender(req)
   393  	if err != nil {
   394  		result.Response = autorest.Response{Response: resp}
   395  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListApplicationVersionPatternFeatures", resp, "Failure sending request")
   396  		return
   397  	}
   398  
   399  	result, err = client.ListApplicationVersionPatternFeaturesResponder(resp)
   400  	if err != nil {
   401  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListApplicationVersionPatternFeatures", resp, "Failure responding to request")
   402  		return
   403  	}
   404  
   405  	return
   406  }
   407  
   408  // ListApplicationVersionPatternFeaturesPreparer prepares the ListApplicationVersionPatternFeatures request.
   409  func (client FeaturesClient) ListApplicationVersionPatternFeaturesPreparer(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (*http.Request, error) {
   410  	urlParameters := map[string]interface{}{
   411  		"Endpoint": client.Endpoint,
   412  	}
   413  
   414  	pathParameters := map[string]interface{}{
   415  		"appId":     autorest.Encode("path", appID),
   416  		"versionId": autorest.Encode("path", versionID),
   417  	}
   418  
   419  	queryParameters := map[string]interface{}{}
   420  	if skip != nil {
   421  		queryParameters["skip"] = autorest.Encode("query", *skip)
   422  	} else {
   423  		queryParameters["skip"] = autorest.Encode("query", 0)
   424  	}
   425  	if take != nil {
   426  		queryParameters["take"] = autorest.Encode("query", *take)
   427  	} else {
   428  		queryParameters["take"] = autorest.Encode("query", 100)
   429  	}
   430  
   431  	preparer := autorest.CreatePreparer(
   432  		autorest.AsGet(),
   433  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   434  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/patterns", pathParameters),
   435  		autorest.WithQueryParameters(queryParameters))
   436  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   437  }
   438  
   439  // ListApplicationVersionPatternFeaturesSender sends the ListApplicationVersionPatternFeatures request. The method will close the
   440  // http.Response Body if it receives an error.
   441  func (client FeaturesClient) ListApplicationVersionPatternFeaturesSender(req *http.Request) (*http.Response, error) {
   442  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   443  }
   444  
   445  // ListApplicationVersionPatternFeaturesResponder handles the response to the ListApplicationVersionPatternFeatures request. The method always
   446  // closes the http.Response Body.
   447  func (client FeaturesClient) ListApplicationVersionPatternFeaturesResponder(resp *http.Response) (result ListPatternFeatureInfo, err error) {
   448  	err = autorest.Respond(
   449  		resp,
   450  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   451  		autorest.ByUnmarshallingJSON(&result.Value),
   452  		autorest.ByClosing())
   453  	result.Response = autorest.Response{Response: resp}
   454  	return
   455  }
   456  
   457  // ListPhraseLists gets all the phraselist features in a version of the application.
   458  // Parameters:
   459  // appID - the application ID.
   460  // versionID - the version ID.
   461  // skip - the number of entries to skip. Default value is 0.
   462  // take - the number of entries to return. Maximum page size is 500. Default is 100.
   463  func (client FeaturesClient) ListPhraseLists(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (result ListPhraseListFeatureInfo, err error) {
   464  	if tracing.IsEnabled() {
   465  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.ListPhraseLists")
   466  		defer func() {
   467  			sc := -1
   468  			if result.Response.Response != nil {
   469  				sc = result.Response.Response.StatusCode
   470  			}
   471  			tracing.EndSpan(ctx, sc, err)
   472  		}()
   473  	}
   474  	if err := validation.Validate([]validation.Validation{
   475  		{TargetValue: skip,
   476  			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
   477  				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}}}}},
   478  		{TargetValue: take,
   479  			Constraints: []validation.Constraint{{Target: "take", Name: validation.Null, Rule: false,
   480  				Chain: []validation.Constraint{{Target: "take", Name: validation.InclusiveMaximum, Rule: int64(500), Chain: nil},
   481  					{Target: "take", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil},
   482  				}}}}}); err != nil {
   483  		return result, validation.NewError("authoring.FeaturesClient", "ListPhraseLists", err.Error())
   484  	}
   485  
   486  	req, err := client.ListPhraseListsPreparer(ctx, appID, versionID, skip, take)
   487  	if err != nil {
   488  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListPhraseLists", nil, "Failure preparing request")
   489  		return
   490  	}
   491  
   492  	resp, err := client.ListPhraseListsSender(req)
   493  	if err != nil {
   494  		result.Response = autorest.Response{Response: resp}
   495  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListPhraseLists", resp, "Failure sending request")
   496  		return
   497  	}
   498  
   499  	result, err = client.ListPhraseListsResponder(resp)
   500  	if err != nil {
   501  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "ListPhraseLists", resp, "Failure responding to request")
   502  		return
   503  	}
   504  
   505  	return
   506  }
   507  
   508  // ListPhraseListsPreparer prepares the ListPhraseLists request.
   509  func (client FeaturesClient) ListPhraseListsPreparer(ctx context.Context, appID uuid.UUID, versionID string, skip *int32, take *int32) (*http.Request, error) {
   510  	urlParameters := map[string]interface{}{
   511  		"Endpoint": client.Endpoint,
   512  	}
   513  
   514  	pathParameters := map[string]interface{}{
   515  		"appId":     autorest.Encode("path", appID),
   516  		"versionId": autorest.Encode("path", versionID),
   517  	}
   518  
   519  	queryParameters := map[string]interface{}{}
   520  	if skip != nil {
   521  		queryParameters["skip"] = autorest.Encode("query", *skip)
   522  	} else {
   523  		queryParameters["skip"] = autorest.Encode("query", 0)
   524  	}
   525  	if take != nil {
   526  		queryParameters["take"] = autorest.Encode("query", *take)
   527  	} else {
   528  		queryParameters["take"] = autorest.Encode("query", 100)
   529  	}
   530  
   531  	preparer := autorest.CreatePreparer(
   532  		autorest.AsGet(),
   533  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   534  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/phraselists", pathParameters),
   535  		autorest.WithQueryParameters(queryParameters))
   536  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   537  }
   538  
   539  // ListPhraseListsSender sends the ListPhraseLists request. The method will close the
   540  // http.Response Body if it receives an error.
   541  func (client FeaturesClient) ListPhraseListsSender(req *http.Request) (*http.Response, error) {
   542  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   543  }
   544  
   545  // ListPhraseListsResponder handles the response to the ListPhraseLists request. The method always
   546  // closes the http.Response Body.
   547  func (client FeaturesClient) ListPhraseListsResponder(resp *http.Response) (result ListPhraseListFeatureInfo, err error) {
   548  	err = autorest.Respond(
   549  		resp,
   550  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   551  		autorest.ByUnmarshallingJSON(&result.Value),
   552  		autorest.ByClosing())
   553  	result.Response = autorest.Response{Response: resp}
   554  	return
   555  }
   556  
   557  // UpdatePhraseList updates the phrases, the state and the name of the phraselist feature in a version of the
   558  // application.
   559  // Parameters:
   560  // appID - the application ID.
   561  // versionID - the version ID.
   562  // phraselistID - the ID of the feature to be updated.
   563  // phraselistUpdateObject - the new values for: - Just a boolean called IsActive, in which case the status of
   564  // the feature will be changed. - Name, Pattern, Mode, and a boolean called IsActive to update the feature.
   565  func (client FeaturesClient) UpdatePhraseList(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32, phraselistUpdateObject *PhraselistUpdateObject) (result OperationStatus, err error) {
   566  	if tracing.IsEnabled() {
   567  		ctx = tracing.StartSpan(ctx, fqdn+"/FeaturesClient.UpdatePhraseList")
   568  		defer func() {
   569  			sc := -1
   570  			if result.Response.Response != nil {
   571  				sc = result.Response.Response.StatusCode
   572  			}
   573  			tracing.EndSpan(ctx, sc, err)
   574  		}()
   575  	}
   576  	req, err := client.UpdatePhraseListPreparer(ctx, appID, versionID, phraselistID, phraselistUpdateObject)
   577  	if err != nil {
   578  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "UpdatePhraseList", nil, "Failure preparing request")
   579  		return
   580  	}
   581  
   582  	resp, err := client.UpdatePhraseListSender(req)
   583  	if err != nil {
   584  		result.Response = autorest.Response{Response: resp}
   585  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "UpdatePhraseList", resp, "Failure sending request")
   586  		return
   587  	}
   588  
   589  	result, err = client.UpdatePhraseListResponder(resp)
   590  	if err != nil {
   591  		err = autorest.NewErrorWithError(err, "authoring.FeaturesClient", "UpdatePhraseList", resp, "Failure responding to request")
   592  		return
   593  	}
   594  
   595  	return
   596  }
   597  
   598  // UpdatePhraseListPreparer prepares the UpdatePhraseList request.
   599  func (client FeaturesClient) UpdatePhraseListPreparer(ctx context.Context, appID uuid.UUID, versionID string, phraselistID int32, phraselistUpdateObject *PhraselistUpdateObject) (*http.Request, error) {
   600  	urlParameters := map[string]interface{}{
   601  		"Endpoint": client.Endpoint,
   602  	}
   603  
   604  	pathParameters := map[string]interface{}{
   605  		"appId":        autorest.Encode("path", appID),
   606  		"phraselistId": autorest.Encode("path", phraselistID),
   607  		"versionId":    autorest.Encode("path", versionID),
   608  	}
   609  
   610  	preparer := autorest.CreatePreparer(
   611  		autorest.AsContentType("application/json; charset=utf-8"),
   612  		autorest.AsPut(),
   613  		autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters),
   614  		autorest.WithPathParameters("/apps/{appId}/versions/{versionId}/phraselists/{phraselistId}", pathParameters))
   615  	if phraselistUpdateObject != nil {
   616  		preparer = autorest.DecoratePreparer(preparer,
   617  			autorest.WithJSON(phraselistUpdateObject))
   618  	}
   619  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   620  }
   621  
   622  // UpdatePhraseListSender sends the UpdatePhraseList request. The method will close the
   623  // http.Response Body if it receives an error.
   624  func (client FeaturesClient) UpdatePhraseListSender(req *http.Request) (*http.Response, error) {
   625  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   626  }
   627  
   628  // UpdatePhraseListResponder handles the response to the UpdatePhraseList request. The method always
   629  // closes the http.Response Body.
   630  func (client FeaturesClient) UpdatePhraseListResponder(resp *http.Response) (result OperationStatus, err error) {
   631  	err = autorest.Respond(
   632  		resp,
   633  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   634  		autorest.ByUnmarshallingJSON(&result),
   635  		autorest.ByClosing())
   636  	result.Response = autorest.Response{Response: resp}
   637  	return
   638  }
   639  

View as plain text