...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/cognitiveservices/v3.0/luis/authoring/features.go

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

View as plain text