diff --git a/profiles/preview/cognitiveservices/luis/authoring/authoringapi/models.go b/profiles/preview/cognitiveservices/luis/authoring/authoringapi/models.go index ceb973c7adbb..b87dd58e85e6 100644 --- a/profiles/preview/cognitiveservices/luis/authoring/authoringapi/models.go +++ b/profiles/preview/cognitiveservices/luis/authoring/authoringapi/models.go @@ -22,6 +22,7 @@ package authoringapi import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v2.0/luis/authoring/authoringapi" type AppsClientAPI = original.AppsClientAPI +type AzureAccountsClientAPI = original.AzureAccountsClientAPI type ExamplesClientAPI = original.ExamplesClientAPI type FeaturesClientAPI = original.FeaturesClientAPI type ModelClientAPI = original.ModelClientAPI diff --git a/profiles/preview/cognitiveservices/luis/authoring/models.go b/profiles/preview/cognitiveservices/luis/authoring/models.go index cec4779072ee..0175f7f7146d 100644 --- a/profiles/preview/cognitiveservices/luis/authoring/models.go +++ b/profiles/preview/cognitiveservices/luis/authoring/models.go @@ -221,6 +221,8 @@ type ApplicationUpdateObject = original.ApplicationUpdateObject type AppsClient = original.AppsClient type AvailableCulture = original.AvailableCulture type AvailablePrebuiltEntityModel = original.AvailablePrebuiltEntityModel +type AzureAccountInfoObject = original.AzureAccountInfoObject +type AzureAccountsClient = original.AzureAccountsClient type BaseClient = original.BaseClient type BatchLabelExample = original.BatchLabelExample type ChildEntity = original.ChildEntity @@ -275,6 +277,7 @@ type ListAppVersionSettingObject = original.ListAppVersionSettingObject type ListApplicationInfoResponse = original.ListApplicationInfoResponse type ListAvailableCulture = original.ListAvailableCulture type ListAvailablePrebuiltEntityModel = original.ListAvailablePrebuiltEntityModel +type ListAzureAccountInfoObject = original.ListAzureAccountInfoObject type ListBatchLabelExample = original.ListBatchLabelExample type ListClosedListEntityExtractor = original.ListClosedListEntityExtractor type ListCompositeEntityExtractor = original.ListCompositeEntityExtractor @@ -363,6 +366,9 @@ func New(endpoint string) BaseClient { func NewAppsClient(endpoint string) AppsClient { return original.NewAppsClient(endpoint) } +func NewAzureAccountsClient(endpoint string) AzureAccountsClient { + return original.NewAzureAccountsClient(endpoint) +} func NewExamplesClient(endpoint string) ExamplesClient { return original.NewExamplesClient(endpoint) } diff --git a/services/cognitiveservices/v2.0/luis/authoring/apps.go b/services/cognitiveservices/v2.0/luis/authoring/apps.go index 185e7404061e..419f412bc74a 100644 --- a/services/cognitiveservices/v2.0/luis/authoring/apps.go +++ b/services/cognitiveservices/v2.0/luis/authoring/apps.go @@ -189,7 +189,8 @@ func (client AppsClient) AddCustomPrebuiltDomainResponder(resp *http.Response) ( // Delete deletes an application. // Parameters: // appID - the application ID. -func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID) (result OperationStatus, err error) { +// force - a flag to indicate whether to force an operation. +func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID, force *bool) (result OperationStatus, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.Delete") defer func() { @@ -200,7 +201,7 @@ func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID) (result Op tracing.EndSpan(ctx, sc, err) }() } - req, err := client.DeletePreparer(ctx, appID) + req, err := client.DeletePreparer(ctx, appID, force) if err != nil { err = autorest.NewErrorWithError(err, "authoring.AppsClient", "Delete", nil, "Failure preparing request") return @@ -222,7 +223,7 @@ func (client AppsClient) Delete(ctx context.Context, appID uuid.UUID) (result Op } // DeletePreparer prepares the Delete request. -func (client AppsClient) DeletePreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) { +func (client AppsClient) DeletePreparer(ctx context.Context, appID uuid.UUID, force *bool) (*http.Request, error) { urlParameters := map[string]interface{}{ "Endpoint": client.Endpoint, } @@ -231,10 +232,18 @@ func (client AppsClient) DeletePreparer(ctx context.Context, appID uuid.UUID) (* "appId": autorest.Encode("path", appID), } + queryParameters := map[string]interface{}{} + if force != nil { + queryParameters["force"] = autorest.Encode("query", *force) + } else { + queryParameters["force"] = autorest.Encode("query", false) + } + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), - autorest.WithPathParameters("/apps/{appId}", pathParameters)) + autorest.WithPathParameters("/apps/{appId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -1191,6 +1200,152 @@ func (client AppsClient) ListUsageScenariosResponder(resp *http.Response) (resul return } +// PackagePublishedApplicationAsGzip packages published LUIS application as GZip. +// Parameters: +// appID - the application ID. +// slotName - the publishing slot name. +func (client AppsClient) PackagePublishedApplicationAsGzip(ctx context.Context, appID uuid.UUID, slotName uuid.UUID) (result ReadCloser, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.PackagePublishedApplicationAsGzip") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PackagePublishedApplicationAsGzipPreparer(ctx, appID, slotName) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", nil, "Failure preparing request") + return + } + + resp, err := client.PackagePublishedApplicationAsGzipSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", resp, "Failure sending request") + return + } + + result, err = client.PackagePublishedApplicationAsGzipResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackagePublishedApplicationAsGzip", resp, "Failure responding to request") + } + + return +} + +// PackagePublishedApplicationAsGzipPreparer prepares the PackagePublishedApplicationAsGzip request. +func (client AppsClient) PackagePublishedApplicationAsGzipPreparer(ctx context.Context, appID uuid.UUID, slotName uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "appId": autorest.Encode("path", appID), + "slotName": autorest.Encode("path", slotName), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPathParameters("/package/{appId}/slot/{slotName}/gzip", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PackagePublishedApplicationAsGzipSender sends the PackagePublishedApplicationAsGzip request. The method will close the +// http.Response Body if it receives an error. +func (client AppsClient) PackagePublishedApplicationAsGzipSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PackagePublishedApplicationAsGzipResponder handles the response to the PackagePublishedApplicationAsGzip request. The method always +// closes the http.Response Body. +func (client AppsClient) PackagePublishedApplicationAsGzipResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + +// PackageTrainedApplicationAsGzip packages trained LUIS application as GZip. +// Parameters: +// appID - the application ID. +// versionID - the version ID. +func (client AppsClient) PackageTrainedApplicationAsGzip(ctx context.Context, appID uuid.UUID, versionID string) (result ReadCloser, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AppsClient.PackageTrainedApplicationAsGzip") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PackageTrainedApplicationAsGzipPreparer(ctx, appID, versionID) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", nil, "Failure preparing request") + return + } + + resp, err := client.PackageTrainedApplicationAsGzipSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", resp, "Failure sending request") + return + } + + result, err = client.PackageTrainedApplicationAsGzipResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AppsClient", "PackageTrainedApplicationAsGzip", resp, "Failure responding to request") + } + + return +} + +// PackageTrainedApplicationAsGzipPreparer prepares the PackageTrainedApplicationAsGzip request. +func (client AppsClient) PackageTrainedApplicationAsGzipPreparer(ctx context.Context, appID uuid.UUID, versionID string) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "appId": autorest.Encode("path", appID), + "versionId": autorest.Encode("path", versionID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPathParameters("/package/{appId}/versions/{versionId}/gzip", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PackageTrainedApplicationAsGzipSender sends the PackageTrainedApplicationAsGzip request. The method will close the +// http.Response Body if it receives an error. +func (client AppsClient) PackageTrainedApplicationAsGzipSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PackageTrainedApplicationAsGzipResponder handles the response to the PackageTrainedApplicationAsGzip request. The method always +// closes the http.Response Body. +func (client AppsClient) PackageTrainedApplicationAsGzipResponder(resp *http.Response) (result ReadCloser, err error) { + result.Value = &resp.Body + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK)) + result.Response = autorest.Response{Response: resp} + return +} + // Publish publishes a specific version of the application. // Parameters: // appID - the application ID. @@ -1260,7 +1415,7 @@ func (client AppsClient) PublishResponder(resp *http.Response) (result Productio err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusMultiStatus), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} diff --git a/services/cognitiveservices/v2.0/luis/authoring/authoringapi/interfaces.go b/services/cognitiveservices/v2.0/luis/authoring/authoringapi/interfaces.go index a89bb1954453..3ac74b39d11d 100644 --- a/services/cognitiveservices/v2.0/luis/authoring/authoringapi/interfaces.go +++ b/services/cognitiveservices/v2.0/luis/authoring/authoringapi/interfaces.go @@ -161,7 +161,7 @@ var _ ModelClientAPI = (*authoring.ModelClient)(nil) type AppsClientAPI interface { Add(ctx context.Context, applicationCreateObject authoring.ApplicationCreateObject) (result authoring.UUID, err error) AddCustomPrebuiltDomain(ctx context.Context, prebuiltDomainCreateObject authoring.PrebuiltDomainCreateObject) (result authoring.UUID, err error) - Delete(ctx context.Context, appID uuid.UUID) (result authoring.OperationStatus, err error) + Delete(ctx context.Context, appID uuid.UUID, force *bool) (result authoring.OperationStatus, err error) DownloadQueryLogs(ctx context.Context, appID uuid.UUID) (result authoring.ReadCloser, err error) Get(ctx context.Context, appID uuid.UUID) (result authoring.ApplicationInfoResponse, err error) GetPublishSettings(ctx context.Context, appID uuid.UUID) (result authoring.PublishSettings, err error) @@ -175,6 +175,8 @@ type AppsClientAPI interface { ListEndpoints(ctx context.Context, appID uuid.UUID) (result authoring.SetString, err error) ListSupportedCultures(ctx context.Context) (result authoring.ListAvailableCulture, err error) ListUsageScenarios(ctx context.Context) (result authoring.ListString, err error) + PackagePublishedApplicationAsGzip(ctx context.Context, appID uuid.UUID, slotName uuid.UUID) (result authoring.ReadCloser, err error) + PackageTrainedApplicationAsGzip(ctx context.Context, appID uuid.UUID, versionID string) (result authoring.ReadCloser, err error) Publish(ctx context.Context, appID uuid.UUID, applicationPublishObject authoring.ApplicationPublishObject) (result authoring.ProductionOrStagingEndpointInfo, err error) Update(ctx context.Context, appID uuid.UUID, applicationUpdateObject authoring.ApplicationUpdateObject) (result authoring.OperationStatus, err error) UpdatePublishSettings(ctx context.Context, appID uuid.UUID, publishSettingUpdateObject authoring.PublishSettingUpdateObject) (result authoring.OperationStatus, err error) @@ -236,3 +238,13 @@ type SettingsClientAPI interface { } var _ SettingsClientAPI = (*authoring.SettingsClient)(nil) + +// AzureAccountsClientAPI contains the set of methods on the AzureAccountsClient type. +type AzureAccountsClientAPI interface { + AssignToApp(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *authoring.AzureAccountInfoObject) (result authoring.OperationStatus, err error) + GetAssigned(ctx context.Context, appID uuid.UUID) (result authoring.ListAzureAccountInfoObject, err error) + GetUserLUISAccounts(ctx context.Context) (result authoring.ListAzureAccountInfoObject, err error) + RemoveFromApp(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *authoring.AzureAccountInfoObject) (result authoring.OperationStatus, err error) +} + +var _ AzureAccountsClientAPI = (*authoring.AzureAccountsClient)(nil) diff --git a/services/cognitiveservices/v2.0/luis/authoring/azureaccounts.go b/services/cognitiveservices/v2.0/luis/authoring/azureaccounts.go new file mode 100644 index 000000000000..4c37df1311c7 --- /dev/null +++ b/services/cognitiveservices/v2.0/luis/authoring/azureaccounts.go @@ -0,0 +1,352 @@ +package authoring + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// AzureAccountsClient is the client for the AzureAccounts methods of the Authoring service. +type AzureAccountsClient struct { + BaseClient +} + +// NewAzureAccountsClient creates an instance of the AzureAccountsClient client. +func NewAzureAccountsClient(endpoint string) AzureAccountsClient { + return AzureAccountsClient{New(endpoint)} +} + +// AssignToApp assigns an azure account to the application. +// Parameters: +// appID - the application ID. +// azureAccountInfoObject - the azure account information object. +func (client AzureAccountsClient) AssignToApp(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *AzureAccountInfoObject) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureAccountsClient.AssignToApp") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: azureAccountInfoObject, + Constraints: []validation.Constraint{{Target: "azureAccountInfoObject", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "azureAccountInfoObject.AzureSubscriptionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "azureAccountInfoObject.ResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "azureAccountInfoObject.AccountName", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authoring.AzureAccountsClient", "AssignToApp", err.Error()) + } + + req, err := client.AssignToAppPreparer(ctx, appID, azureAccountInfoObject) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "AssignToApp", nil, "Failure preparing request") + return + } + + resp, err := client.AssignToAppSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "AssignToApp", resp, "Failure sending request") + return + } + + result, err = client.AssignToAppResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "AssignToApp", resp, "Failure responding to request") + } + + return +} + +// AssignToAppPreparer prepares the AssignToApp request. +func (client AzureAccountsClient) AssignToAppPreparer(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *AzureAccountInfoObject) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "appId": autorest.Encode("path", appID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPathParameters("/apps/{appId}/azureaccounts", pathParameters)) + if azureAccountInfoObject != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(azureAccountInfoObject)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// AssignToAppSender sends the AssignToApp request. The method will close the +// http.Response Body if it receives an error. +func (client AzureAccountsClient) AssignToAppSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// AssignToAppResponder handles the response to the AssignToApp request. The method always +// closes the http.Response Body. +func (client AzureAccountsClient) AssignToAppResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAssigned gets the LUIS azure accounts assigned to the application for the user using his ARM token. +// Parameters: +// appID - the application ID. +func (client AzureAccountsClient) GetAssigned(ctx context.Context, appID uuid.UUID) (result ListAzureAccountInfoObject, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureAccountsClient.GetAssigned") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetAssignedPreparer(ctx, appID) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetAssigned", nil, "Failure preparing request") + return + } + + resp, err := client.GetAssignedSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetAssigned", resp, "Failure sending request") + return + } + + result, err = client.GetAssignedResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetAssigned", resp, "Failure responding to request") + } + + return +} + +// GetAssignedPreparer prepares the GetAssigned request. +func (client AzureAccountsClient) GetAssignedPreparer(ctx context.Context, appID uuid.UUID) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "appId": autorest.Encode("path", appID), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPathParameters("/apps/{appId}/azureaccounts", pathParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetAssignedSender sends the GetAssigned request. The method will close the +// http.Response Body if it receives an error. +func (client AzureAccountsClient) GetAssignedSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetAssignedResponder handles the response to the GetAssigned request. The method always +// closes the http.Response Body. +func (client AzureAccountsClient) GetAssignedResponder(resp *http.Response) (result ListAzureAccountInfoObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetUserLUISAccounts gets the LUIS azure accounts for the user using his ARM token. +func (client AzureAccountsClient) GetUserLUISAccounts(ctx context.Context) (result ListAzureAccountInfoObject, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureAccountsClient.GetUserLUISAccounts") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetUserLUISAccountsPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetUserLUISAccounts", nil, "Failure preparing request") + return + } + + resp, err := client.GetUserLUISAccountsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetUserLUISAccounts", resp, "Failure sending request") + return + } + + result, err = client.GetUserLUISAccountsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "GetUserLUISAccounts", resp, "Failure responding to request") + } + + return +} + +// GetUserLUISAccountsPreparer prepares the GetUserLUISAccounts request. +func (client AzureAccountsClient) GetUserLUISAccountsPreparer(ctx context.Context) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPath("/azureaccounts")) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetUserLUISAccountsSender sends the GetUserLUISAccounts request. The method will close the +// http.Response Body if it receives an error. +func (client AzureAccountsClient) GetUserLUISAccountsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetUserLUISAccountsResponder handles the response to the GetUserLUISAccounts request. The method always +// closes the http.Response Body. +func (client AzureAccountsClient) GetUserLUISAccountsResponder(resp *http.Response) (result ListAzureAccountInfoObject, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RemoveFromApp removes assigned azure account from the application. +// Parameters: +// appID - the application ID. +// azureAccountInfoObject - the azure account information object. +func (client AzureAccountsClient) RemoveFromApp(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *AzureAccountInfoObject) (result OperationStatus, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AzureAccountsClient.RemoveFromApp") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: azureAccountInfoObject, + Constraints: []validation.Constraint{{Target: "azureAccountInfoObject", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "azureAccountInfoObject.AzureSubscriptionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "azureAccountInfoObject.ResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "azureAccountInfoObject.AccountName", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("authoring.AzureAccountsClient", "RemoveFromApp", err.Error()) + } + + req, err := client.RemoveFromAppPreparer(ctx, appID, azureAccountInfoObject) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "RemoveFromApp", nil, "Failure preparing request") + return + } + + resp, err := client.RemoveFromAppSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "RemoveFromApp", resp, "Failure sending request") + return + } + + result, err = client.RemoveFromAppResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "authoring.AzureAccountsClient", "RemoveFromApp", resp, "Failure responding to request") + } + + return +} + +// RemoveFromAppPreparer prepares the RemoveFromApp request. +func (client AzureAccountsClient) RemoveFromAppPreparer(ctx context.Context, appID uuid.UUID, azureAccountInfoObject *AzureAccountInfoObject) (*http.Request, error) { + urlParameters := map[string]interface{}{ + "Endpoint": client.Endpoint, + } + + pathParameters := map[string]interface{}{ + "appId": autorest.Encode("path", appID), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithCustomBaseURL("{Endpoint}/luis/api/v2.0", urlParameters), + autorest.WithPathParameters("/apps/{appId}/azureaccounts", pathParameters)) + if azureAccountInfoObject != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(azureAccountInfoObject)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RemoveFromAppSender sends the RemoveFromApp request. The method will close the +// http.Response Body if it receives an error. +func (client AzureAccountsClient) RemoveFromAppSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// RemoveFromAppResponder handles the response to the RemoveFromApp request. The method always +// closes the http.Response Body. +func (client AzureAccountsClient) RemoveFromAppResponder(resp *http.Response) (result OperationStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cognitiveservices/v2.0/luis/authoring/models.go b/services/cognitiveservices/v2.0/luis/authoring/models.go index c25bb5fa7578..3770fac7c6e8 100644 --- a/services/cognitiveservices/v2.0/luis/authoring/models.go +++ b/services/cognitiveservices/v2.0/luis/authoring/models.go @@ -523,6 +523,16 @@ type AvailablePrebuiltEntityModel struct { Examples *string `json:"examples,omitempty"` } +// AzureAccountInfoObject defines the azure account information object. +type AzureAccountInfoObject struct { + // AzureSubscriptionID - The id for the azure subscription. + AzureSubscriptionID *string `json:"azureSubscriptionId,omitempty"` + // ResourceGroup - The azure resource group name. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // AccountName - The azure account name. + AccountName *string `json:"accountName,omitempty"` +} + // BatchLabelExample response when adding a batch of labeled examples. type BatchLabelExample struct { Value *LabelExampleResponse `json:"value,omitempty"` @@ -651,6 +661,8 @@ type EndpointInfo struct { AssignedEndpointKey *string `json:"assignedEndpointKey,omitempty"` // EndpointRegion - The endpoint's region. EndpointRegion *string `json:"endpointRegion,omitempty"` + // FailedRegions - Regions where publishing failed. + FailedRegions *string `json:"failedRegions,omitempty"` // PublishedDateTime - Timestamp when was last published. PublishedDateTime *string `json:"publishedDateTime,omitempty"` } @@ -1062,6 +1074,12 @@ type ListAvailablePrebuiltEntityModel struct { Value *[]AvailablePrebuiltEntityModel `json:"value,omitempty"` } +// ListAzureAccountInfoObject ... +type ListAzureAccountInfoObject struct { + autorest.Response `json:"-"` + Value *[]AzureAccountInfoObject `json:"value,omitempty"` +} + // ListBatchLabelExample ... type ListBatchLabelExample struct { autorest.Response `json:"-"` @@ -1788,6 +1806,8 @@ type ProductionOrStagingEndpointInfo struct { AssignedEndpointKey *string `json:"assignedEndpointKey,omitempty"` // EndpointRegion - The endpoint's region. EndpointRegion *string `json:"endpointRegion,omitempty"` + // FailedRegions - Regions where publishing failed. + FailedRegions *string `json:"failedRegions,omitempty"` // PublishedDateTime - Timestamp when was last published. PublishedDateTime *string `json:"publishedDateTime,omitempty"` }