From 738ddb0bb37040552136d17c6691095fac2000a0 Mon Sep 17 00:00:00 2001 From: Yuhan Yao Date: Wed, 19 Aug 2020 22:17:13 +0800 Subject: [PATCH 1/2] fix some bugs --- .../Admin/Luna.AI/AMLWorkspaceController.cs | 14 +- .../Admin/Luna.AI/APIVersionController.cs | 4 +- .../Azure/Auth/IKeyVaultHelper.cs | 6 +- .../Luna.Clients/Azure/Auth/KeyVaultHelper.cs | 49 ++++- .../Azure/Auth/SecretUpdateHelper.cs | 14 ++ .../Controller/ControllerHelper.cs | 20 ++- .../Exceptions/LunaDbSaveException.cs | 41 +++++ .../Luna.Clients/Exceptions/UserErrorCode.cs | 5 +- .../src/Luna.Clients/Logging/LoggingUtils.cs | 7 +- .../Luna.Data/Entities/Luna.AI/APIVersion.cs | 10 +- .../Data/Luna.AI/AMLWorkspaceService.cs | 105 +++++++---- .../Data/Luna.AI/APISubscriptionService.cs | 6 +- .../Data/Luna.AI/APIVersionService.cs | 167 +++++++++++++++--- .../Data/Luna.AI/DeploymentService.cs | 9 +- .../Data/Luna.AI/ProductService.cs | 10 +- 15 files changed, 386 insertions(+), 81 deletions(-) create mode 100644 end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/SecretUpdateHelper.cs create mode 100644 end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/LunaDbSaveException.cs diff --git a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/AMLWorkspaceController.cs b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/AMLWorkspaceController.cs index 2c92eca..591d99d 100644 --- a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/AMLWorkspaceController.cs +++ b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/AMLWorkspaceController.cs @@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Microsoft.Azure.Services.AppAuthentication; +using Microsoft.Azure.KeyVault; namespace Luna.API.Controllers.Admin { @@ -84,6 +86,13 @@ public async Task GetAsync(string workspaceName) return Ok(await _workspaceService.GetAsync(workspaceName)); } + public async Task Test() + { + var azureServiceTokenProvider = new AzureServiceTokenProvider(); + string test = azureServiceTokenProvider.KeyVaultTokenCallback.ToString(); + return test; + } + /// /// Creates or updates an workspace. /// @@ -95,7 +104,6 @@ public async Task GetAsync(string workspaceName) [ProducesResponseType(StatusCodes.Status200OK)] public async Task CreateOrUpdateAsync(string workspaceName, [FromBody] AMLWorkspace workspace) { - AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); if (workspace == null) { throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(nameof(workspace)), UserErrorCode.PayloadNotProvided); @@ -109,13 +117,13 @@ public async Task CreateOrUpdateAsync(string workspaceName, [FromB if (await _workspaceService.ExistsAsync(workspaceName)) { - _logger.LogInformation($"Update workspace {workspaceName} with payload {JsonConvert.SerializeObject(workspace)}"); + _logger.LogInformation($"Update workspace with {workspaceName}"); await _workspaceService.UpdateAsync(workspaceName, workspace); return Ok(workspace); } else { - _logger.LogInformation($"Create workspace {workspaceName} with payload {JsonConvert.SerializeObject(workspace)}"); + _logger.LogInformation($"Create workspace with {workspaceName}"); await _workspaceService.CreateAsync(workspace); return CreatedAtRoute(nameof(GetAsync) + nameof(AMLWorkspace), new { workspaceName = workspace.WorkspaceName }, workspace); } diff --git a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs index 5875214..22192d9 100644 --- a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs +++ b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs @@ -101,13 +101,13 @@ public async Task CreateOrUpdateAsync(string productName, string d if(await _apiVersionService.ExistsAsync(productName, deploymentName, versionName)) { - _logger.LogInformation($"Update apiVersion {versionName} in deployment {deploymentName} in product {productName} with payload {JsonSerializer.Serialize(apiVersion)}."); + _logger.LogInformation($"Update apiVersion {versionName} in deployment {deploymentName} in product {productName}."); apiVersion = await _apiVersionService.UpdateAsync(productName, deploymentName, versionName, apiVersion); return Ok(apiVersion); } else { - _logger.LogInformation($"Create apiVersion {versionName} in deployment {deploymentName} in product {productName} with payload {JsonSerializer.Serialize(apiVersion)}."); + _logger.LogInformation($"Create apiVersion {versionName} in deployment {deploymentName} in product {productName}."); await _apiVersionService.CreateAsync(productName, deploymentName, apiVersion); return CreatedAtRoute(nameof(GetAsync) + nameof(APIVersion), new { productName = productName, deploymentName = deploymentName, versionName = versionName }, apiVersion); } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/IKeyVaultHelper.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/IKeyVaultHelper.cs index b028cb8..367d7bd 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/IKeyVaultHelper.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/IKeyVaultHelper.cs @@ -1,8 +1,9 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System.Threading.Tasks; using Microsoft.Azure.KeyVault.WebKey; +using Microsoft.Azure.KeyVault.Models; namespace Luna.Clients.Azure.Auth { @@ -11,6 +12,9 @@ public interface IKeyVaultHelper Task SetSecretAsync(string vaultName, string secretName, string value); Task GetSecretAsync(string vaultName, string secretName); Task DeleteSecretAsync(string vaultName, string secretName); + Task GetSecretVersionsAsync(string vaultName, string secretName); + Task DisableVersionAsync(string secretIdentifier, SecretAttributes secretAttributes); + Task EnableVersionAsync(string secretIdentifier, SecretAttributes secretAttributes); Task GetKeyAsync(string vaultName, string keyName); diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/KeyVaultHelper.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/KeyVaultHelper.cs index 969603d..5f90e7c 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/KeyVaultHelper.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/KeyVaultHelper.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -8,6 +8,7 @@ using Microsoft.Azure.Services.AppAuthentication; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Clients.ActiveDirectory; +using Microsoft.Azure.KeyVault.Models; namespace Luna.Clients.Azure.Auth { @@ -106,5 +107,51 @@ public async Task GetBearerToken(AuthenticationConfiguration options, st } } + public async Task GetSecretVersionsAsync(string vaultName, string secretName) + { + try + { + _logger.LogInformation("GetSecretVersionsAsync from KeyVault"); + var secret = await keyVaultClient.GetSecretAsync($"https://{vaultName}.vault.azure.net/", secretName); + _logger.LogInformation("GetSecretVersionsAsync operation completed"); + return secret; + } + catch (Exception ex) + { + throw new InvalidOperationException(ex.Message); + } + } + + public async Task DisableVersionAsync(string secretIdentifier, SecretAttributes secretAttributes) + { + try + { + _logger.LogInformation("Disable a specified version secret with secretIdentifier"); + secretAttributes.Enabled = false; + var secretUpdate = await keyVaultClient.UpdateSecretAsync(secretIdentifier, default, secretAttributes); + _logger.LogInformation($"Disable the {secretIdentifier} version operation completed"); + return secretUpdate.Value; + } + catch (Exception ex) + { + throw new InvalidOperationException(ex.Message); + } + } + + public async Task EnableVersionAsync(string secretIdentifier, SecretAttributes secretAttributes) + { + try + { + _logger.LogInformation("Enable a specified version secret with secretIdentifier"); + secretAttributes.Enabled = true; + var secretUpdate = await keyVaultClient.UpdateSecretAsync(secretIdentifier, default, secretAttributes); + _logger.LogInformation($"Enable the {secretIdentifier} version operation completed"); + return secretUpdate.Value; + } + catch (Exception ex) + { + throw new InvalidOperationException(ex.Message); + } + } } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/SecretUpdateHelper.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/SecretUpdateHelper.cs new file mode 100644 index 0000000..bbd3073 --- /dev/null +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/Auth/SecretUpdateHelper.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Luna.Clients.Azure.Auth +{ + public class SecretUpdateHelper + { + + } +} diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs index 82becea..8a98d59 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs @@ -1,10 +1,12 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Collections.Generic; +using System.IO.Compression; using System.Net.Http; using System.Net.Http.Headers; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Luna.Clients.Controller.Auth; using Luna.Clients.Exceptions; @@ -925,5 +927,21 @@ public static async Task DeleteAEndpoint(AMLWorkspace workspace, Guid endpointId throw new LunaServerException($"Query failed with response {responseContent}"); } } + + public static async Task CheckNameValidity(string resourceName, string resource) + { + if (resource.Equals("APIVersion", StringComparison.InvariantCultureIgnoreCase)) + { + Regex regex = new Regex(@"[^0-9a-zA-Z-.]"); + Match match = regex.Match(resourceName); + return match.Success; + } + else + { + Regex regex = new Regex(@"[^0-9a-zA-Z-]"); + Match match = regex.Match(resourceName); + return match.Success; + } + } } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/LunaDbSaveException.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/LunaDbSaveException.cs new file mode 100644 index 0000000..df8e2c6 --- /dev/null +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/LunaDbSaveException.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +using System; + +namespace Luna.Clients.Exceptions +{ + public class LunaDbSaveException : LunaServerException + { + public LunaDbSaveException( + string message, + LunaServerException innerException = default) : base( + message, + innerException.IsRetryable, + innerException) + { + + } + + public LunaDbSaveException( + string message, + bool isRetryable, + Exception innerException = default) : base( + message, + isRetryable, + innerException) + { + + } + + public LunaDbSaveException( + string message, + Exception innerException = default) : base( + message, + false, + innerException) + { + + } + } +} diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/UserErrorCode.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/UserErrorCode.cs index e12ee24..c6a6ad2 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/UserErrorCode.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Exceptions/UserErrorCode.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. namespace Luna.Clients.Exceptions @@ -14,6 +14,7 @@ public enum UserErrorCode ArmTemplateNotProvided, InvalidParameter, Unauthorized, - AuthKeyNotProvided + AuthKeyNotProvided, + PayloadNameInvalid } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Logging/LoggingUtils.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Logging/LoggingUtils.cs index 14f993b..e6e700c 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Logging/LoggingUtils.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Logging/LoggingUtils.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -516,6 +516,11 @@ public static string ComposeSubscriptionActionErrorMessage(Guid subscriptionId, return message.ToString().Trim(); } + + public static string ComposeNameInvalidErrorMessage(string resource, string resourceName) + { + return $"The name {resourceName} of {resource} is invalid."; + } } } diff --git a/end-to-end-solutions/Luna/src/Luna.Data/Entities/Luna.AI/APIVersion.cs b/end-to-end-solutions/Luna/src/Luna.Data/Entities/Luna.AI/APIVersion.cs index e9ac7f0..dccc16d 100644 --- a/end-to-end-solutions/Luna/src/Luna.Data/Entities/Luna.AI/APIVersion.cs +++ b/end-to-end-solutions/Luna/src/Luna.Data/Entities/Luna.AI/APIVersion.cs @@ -34,9 +34,9 @@ public void Copy(APIVersion version) this.TrainModelAPI = version.TrainModelAPI; this.DeployModelAPI = version.DeployModelAPI; this.AuthenticationType = version.AuthenticationType; - this.AuthenticationKey = version.AuthenticationKey; + this.AuthenticationKeySecretName = version.AuthenticationKeySecretName; this.VersionSourceType = version.VersionSourceType; - this.GitPersonalAccessToken = version.GitPersonalAccessToken; + this.GitPersonalAccessTokenSecretName = version.GitPersonalAccessTokenSecretName; this.GitUrl = version.GitUrl; this.GitVersion = version.GitVersion; } @@ -47,9 +47,9 @@ public string GetVersionIdFormat() } [Key] - [System.Text.Json.Serialization.JsonIgnore] + [JsonIgnore] public long Id { get; set; } - [System.Text.Json.Serialization.JsonIgnore] + [JsonIgnore] public long DeploymentId { get; set; } [NotMapped] public string ProductName { get; set; } @@ -80,7 +80,7 @@ public string GetVersionIdFormat() [JsonIgnore] public string AuthenticationKeySecretName { get; set; } - [System.Text.Json.Serialization.JsonIgnore] + [JsonIgnore] public long AMLWorkspaceId { get; set; } [NotMapped] diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/AMLWorkspaceService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/AMLWorkspaceService.cs index 421a607..2149aa1 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/AMLWorkspaceService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/AMLWorkspaceService.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using Luna.Clients.Azure.Auth; +using Luna.Clients.Azure.Auth; using Luna.Clients.Controller; using Luna.Clients.Exceptions; using Luna.Clients.Logging; @@ -17,6 +17,9 @@ using System.Threading.Tasks; using Luna.Clients.Azure.APIM; using Luna.Services.Utilities.ExpressionEvaluation; +using Microsoft.Azure.KeyVault.Models; +using Microsoft.Azure.Services.AppAuthentication; +using Microsoft.Azure.KeyVault; namespace Luna.Services.Data.Luna.AI { @@ -26,7 +29,6 @@ public class AMLWorkspaceService : IAMLWorkspaceService private readonly ILogger _logger; private readonly IKeyVaultHelper _keyVaultHelper; private readonly IOptionsMonitor _options; - /// /// Constructor that uses dependency injection. /// @@ -60,16 +62,16 @@ public async Task GetAsync(string workspaceName) { if (!await ExistsAsync(workspaceName)) { - throw new LunaNotFoundUserException(LoggingUtils.ComposeNotFoundErrorMessage(typeof(Product).Name, + throw new LunaNotFoundUserException(LoggingUtils.ComposeNotFoundErrorMessage(typeof(AMLWorkspace).Name, workspaceName)); } - _logger.LogInformation(LoggingUtils.ComposeGetSingleResourceMessage(typeof(Product).Name, workspaceName)); + _logger.LogInformation(LoggingUtils.ComposeGetSingleResourceMessage(typeof(AMLWorkspace).Name, workspaceName)); // Get the product that matches the provided productName var workspace = await _context.AMLWorkspaces.SingleOrDefaultAsync(o => (o.WorkspaceName == workspaceName)); workspace.AADApplicationSecrets = await _keyVaultHelper.GetSecretAsync(_options.CurrentValue.Config.VaultName, workspace.AADApplicationSecretName); - _logger.LogInformation(LoggingUtils.ComposeReturnValueMessage(typeof(Product).Name, + _logger.LogInformation(LoggingUtils.ComposeReturnValueMessage(typeof(AMLWorkspace).Name, workspaceName, JsonSerializer.Serialize(workspace))); @@ -111,13 +113,20 @@ public async Task CreateAsync(AMLWorkspace workspace) UserErrorCode.PayloadNotProvided); } + // Check if WorkspaceName is valid + if (await ControllerHelper.CheckNameValidity(workspace.WorkspaceName, nameof(AMLWorkspace))) + { + throw new LunaBadRequestUserException(LoggingUtils.ComposeNameInvalidErrorMessage(nameof(AMLWorkspace), workspace.WorkspaceName), + UserErrorCode.PayloadNameInvalid); + } + // Check that an offer with the same name does not already exist if (await ExistsAsync(workspace.WorkspaceName)) { throw new LunaConflictUserException(LoggingUtils.ComposeAlreadyExistsErrorMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); } - _logger.LogInformation(LoggingUtils.ComposeCreateResourceMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName, payload: JsonSerializer.Serialize(workspace))); + _logger.LogInformation(LoggingUtils.ComposeCreateResourceMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); workspace.Region = await ControllerHelper.GetRegion(workspace); @@ -130,10 +139,19 @@ public async Task CreateAsync(AMLWorkspace workspace) await (_keyVaultHelper.SetSecretAsync(_options.CurrentValue.Config.VaultName, secretName, workspace.AADApplicationSecrets)); // Add workspace to db - workspace.AADApplicationSecretName = secretName; - _context.AMLWorkspaces.Add(workspace); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); + try + { + workspace.AADApplicationSecretName = secretName; + _context.AMLWorkspaces.Add(workspace); + await _context._SaveChangesAsync(); + _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); + } + catch (Exception e) + { + await (_keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, secretName)); + throw new LunaDbSaveException(e.InnerException.Message, e); + } + return workspace; } @@ -145,8 +163,8 @@ public async Task UpdateAsync(string workspaceName, AMLWorkspace w throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(typeof(AMLWorkspace).Name), UserErrorCode.PayloadNotProvided); } - _logger.LogInformation(LoggingUtils.ComposeUpdateResourceMessage(typeof(Product).Name, workspace.WorkspaceName, payload: JsonSerializer.Serialize(workspace))); - + _logger.LogInformation(LoggingUtils.ComposeUpdateResourceMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); + // Get the offer that matches the offerName provided var workspaceDb = await GetAsync(workspaceName); @@ -158,23 +176,41 @@ public async Task UpdateAsync(string workspaceName, AMLWorkspace w UserErrorCode.NameMismatch); } + workspace.Region = await ControllerHelper.GetRegion(workspace); + // Add secret to keyvault if (workspace.AADApplicationSecrets == null) { throw new LunaBadRequestUserException("AAD Application Secrets is needed with the aml workspace", UserErrorCode.ArmTemplateNotProvided); } - string secretName = string.IsNullOrEmpty(workspace.AADApplicationSecretName) ? $"amlkey-{Context.GetRandomString(12)}" : workspace.AADApplicationSecretName; + string secretName = string.IsNullOrEmpty(workspaceDb.AADApplicationSecretName) ? $"amlkey-{Context.GetRandomString(12)}" : workspaceDb.AADApplicationSecretName; + + // Get old version from keyvault + var oldVersion = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, secretName); await (_keyVaultHelper.SetSecretAsync(_options.CurrentValue.Config.VaultName, secretName, workspace.AADApplicationSecrets)); // Copy over the changes - workspace.Region = await ControllerHelper.GetRegion(workspace); + workspace.AADApplicationSecretName = secretName; workspaceDb.Copy(workspace); - // Update workspaceDb values and save changes in db - _context.AMLWorkspaces.Update(workspaceDb); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceUpdatedMessage(typeof(Product).Name, workspace.WorkspaceName)); + try + { + // Update workspaceDb values and save changes in db + _context.AMLWorkspaces.Update(workspaceDb); + await _context._SaveChangesAsync(); + // Disable old version secret + await _keyVaultHelper.DisableVersionAsync(oldVersion.SecretIdentifier.Identifier, oldVersion.Attributes); + _logger.LogInformation(LoggingUtils.ComposeResourceUpdatedMessage(typeof(AMLWorkspace).Name, workspace.WorkspaceName)); + } + catch (Exception e) + { + // Disable new version secret + var newVersion = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, secretName); + await _keyVaultHelper.DisableVersionAsync(newVersion.SecretIdentifier.Identifier, newVersion.Attributes); + throw new LunaDbSaveException(e.InnerException.Message, e); + } + return workspaceDb; } @@ -184,23 +220,30 @@ public async Task DeleteAsync(string workspaceName) var workspace = await GetAsync(workspaceName); - // Delete secret from key vault - if (!string.IsNullOrEmpty(workspace.AADApplicationSecretName)) - { - string secretName = workspace.AADApplicationSecretName; - try - { - await (_keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, secretName)); - } - catch { } - } + // Disable current version secret + var currentVersion = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, workspace.AADApplicationSecretName); + await _keyVaultHelper.DisableVersionAsync(currentVersion.SecretIdentifier.Identifier, currentVersion.Attributes); // Remove the workspace from the db - _context.AMLWorkspaces.Remove(workspace); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(AMLWorkspace).Name, workspaceName)); + try + { + _context.AMLWorkspaces.Remove(workspace); + await _context._SaveChangesAsync(); + + // Delete secret from key vault + await (_keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, workspace.AADApplicationSecretName)); + _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(AMLWorkspace).Name, workspaceName)); + } + catch (Exception e) + { + // Enable current version secret + await _keyVaultHelper.EnableVersionAsync(currentVersion.SecretIdentifier.Identifier, currentVersion.Attributes); + throw new LunaDbSaveException(e.InnerException.Message, e); + } + return workspace; } + } } diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APISubscriptionService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APISubscriptionService.cs index bda0ed8..6753a1c 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APISubscriptionService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APISubscriptionService.cs @@ -249,7 +249,7 @@ public async Task UpdateAsync(Guid apiSubscriptionId, APISubscr /// The subscription. public async Task DeleteAsync(Guid apiSubscriptionId) { - _logger.LogInformation(LoggingUtils.ComposeDeleteResourceMessage(typeof(Product).Name, apiSubscriptionId.ToString())); + _logger.LogInformation(LoggingUtils.ComposeDeleteResourceMessage(typeof(APISubscription).Name, apiSubscriptionId.ToString())); // Get the offer that matches the offerName provide var apiSubscription = await GetAsync(apiSubscriptionId); @@ -260,7 +260,7 @@ public async Task DeleteAsync(Guid apiSubscriptionId) // Remove the product from the db _context.APISubscriptions.Remove(apiSubscription); await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(Product).Name, apiSubscriptionId.ToString())); + _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(APISubscription).Name, apiSubscriptionId.ToString())); return apiSubscription; } @@ -320,7 +320,7 @@ public async Task ExistsAsync(Guid apiSubscriptionId) } else { - _logger.LogInformation(LoggingUtils.ComposeResourceExistsOrNotMessage(typeof(Product).Name, apiSubscriptionId.ToString(), true)); + _logger.LogInformation(LoggingUtils.ComposeResourceExistsOrNotMessage(typeof(APISubscription).Name, apiSubscriptionId.ToString(), true)); // count = 1 return true; } diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs index fbf0b6e..1ea6533 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs @@ -4,6 +4,7 @@ using Luna.Clients.Azure.APIM; using Luna.Clients.Exceptions; using Luna.Clients.Logging; +using Luna.Clients.Controller; using Luna.Data.Entities; using Luna.Data.Repository; using Luna.Clients.Azure.Auth; @@ -17,6 +18,7 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Microsoft.Azure.KeyVault.Models; namespace Luna.Services.Data.Luna.AI @@ -252,6 +254,13 @@ public async Task CreateAsync(string productName, string deploymentN UserErrorCode.PayloadNotProvided); } + // Check if VersionName is valid + if (await ControllerHelper.CheckNameValidity(version.VersionName, nameof(APIVersion))) + { + throw new LunaBadRequestUserException(LoggingUtils.ComposeNameInvalidErrorMessage(nameof(APIVersion), version.VersionName), + UserErrorCode.PayloadNameInvalid); + } + // Check that the product and the deployment does not already have an apiVersion with the same versionName if (await ExistsAsync(productName, deploymentName, version.VersionName)) { @@ -263,7 +272,7 @@ public async Task CreateAsync(string productName, string deploymentN { throw new LunaConflictUserException($"Parameter {version.VersionName} is reserved. Please use a different name."); } - _logger.LogInformation(LoggingUtils.ComposeCreateResourceMessage(typeof(APIVersion).Name, version.VersionName, payload: JsonSerializer.Serialize(version))); + _logger.LogInformation(LoggingUtils.ComposeCreateResourceMessage(typeof(APIVersion).Name, version.VersionName)); // Get the product associated with the productName provided var product = await _productService.GetAsync(productName); @@ -298,7 +307,7 @@ public async Task CreateAsync(string productName, string deploymentN // add athentication key to keyVault if authentication type is key if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) { - if (version.AuthenticationKey == null) + if (string.IsNullOrEmpty(version.AuthenticationKey)) { throw new LunaBadRequestUserException("Authentication key is needed with the key authentication type", UserErrorCode.AuthKeyNotProvided); } @@ -327,9 +336,24 @@ public async Task CreateAsync(string productName, string deploymentN } // Add apiVersion to db - _context.APIVersions.Add(version); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(APIVersion).Name, version.VersionName)); + try + { + _context.APIVersions.Add(version); + await _context._SaveChangesAsync(); + _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(APIVersion).Name, version.VersionName)); + } + catch (Exception e) + { + if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) + { + await (_keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, version.AuthenticationKeySecretName)); + } + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + await (_keyVaultHelper.SetSecretAsync(_options.CurrentValue.Config.VaultName, version.GitPersonalAccessTokenSecretName, version.GitPersonalAccessToken)); + } + throw new LunaDbSaveException(e.InnerException.Message, e); + } return version; } @@ -358,7 +382,10 @@ public async Task UpdateAsync(string productName, string deploymentN UserErrorCode.NameMismatch); } - _logger.LogInformation(LoggingUtils.ComposeUpdateResourceMessage(typeof(APIVersion).Name, versionName, payload: JsonSerializer.Serialize(version))); + _logger.LogInformation(LoggingUtils.ComposeUpdateResourceMessage(typeof(APIVersion).Name, versionName)); + + // Get the apiVersion that matches the productName, deploymentName and versionName provided + var versionDb = await GetAsync(productName, deploymentName, versionName); //check if amlworkspace is required if (!string.IsNullOrEmpty(version.AMLWorkspaceName)) @@ -370,36 +397,77 @@ public async Task UpdateAsync(string productName, string deploymentN version = UpdateUrl(version, amlWorkspace); } + SecretBundle oldVersionAuthenticationSecret = new SecretBundle(); + SecretBundle oldVersionGitPersonalAccessTokenSecret = new SecretBundle(); + // add athentication key to keyVault if authentication type is key if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) { - if (version.AuthenticationKey == null) + if (string.IsNullOrEmpty(version.AuthenticationKey)) { throw new LunaBadRequestUserException("Authentication key is needed with the key authentication type", UserErrorCode.AuthKeyNotProvided); } - string secretName = string.IsNullOrEmpty(version.AuthenticationKeySecretName) ? $"authkey-{Context.GetRandomString(12)}" : version.AuthenticationKeySecretName; + + string secretName = string.IsNullOrEmpty(versionDb.AuthenticationKeySecretName) ? $"authkey-{Context.GetRandomString(12)}" : versionDb.AuthenticationKeySecretName; + + // Get old version from keyvault + oldVersionAuthenticationSecret = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, secretName); + await (_keyVaultHelper.SetSecretAsync(_options.CurrentValue.Config.VaultName, secretName, version.AuthenticationKey)); version.AuthenticationKeySecretName = secretName; } if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) { - string secretName = string.IsNullOrEmpty(version.GitPersonalAccessTokenSecretName) ? $"gitpat-{Context.GetRandomString(12)}" : version.GitPersonalAccessTokenSecretName; + string secretName = string.IsNullOrEmpty(versionDb.GitPersonalAccessTokenSecretName) ? $"gitpat-{Context.GetRandomString(12)}" : versionDb.GitPersonalAccessTokenSecretName; + + // Get old version from keyvault + oldVersionGitPersonalAccessTokenSecret = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, secretName); + await (_keyVaultHelper.SetSecretAsync(_options.CurrentValue.Config.VaultName, secretName, version.GitPersonalAccessToken)); version.GitPersonalAccessTokenSecretName = secretName; } - - // Get the apiVersion that matches the productName, deploymentName and versionName provided - var versionDb = await GetAsync(productName, deploymentName, versionName); - + // Copy over the changes versionDb.Copy(version); versionDb.LastUpdatedTime = DateTime.UtcNow; // Update version values and save changes in db - _context.APIVersions.Update(versionDb); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceUpdatedMessage(typeof(APIVersion).Name, versionName)); + try + { + _context.APIVersions.Update(versionDb); + await _context._SaveChangesAsync(); + + // Disable old version secret + if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) + { + await _keyVaultHelper.DisableVersionAsync(oldVersionAuthenticationSecret.SecretIdentifier.Identifier, oldVersionAuthenticationSecret.Attributes); + } + + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + await _keyVaultHelper.DisableVersionAsync(oldVersionGitPersonalAccessTokenSecret.SecretIdentifier.Identifier, oldVersionGitPersonalAccessTokenSecret.Attributes); + } + + _logger.LogInformation(LoggingUtils.ComposeResourceUpdatedMessage(typeof(APIVersion).Name, versionName)); + } + catch (Exception e) + { + // Disable new version secret + if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) + { + var newVersion = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, version.AuthenticationKeySecretName); + await _keyVaultHelper.DisableVersionAsync(newVersion.SecretIdentifier.Identifier, newVersion.Attributes); + } + + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + var newVersion = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, version.GitPersonalAccessTokenSecretName); + await _keyVaultHelper.DisableVersionAsync(newVersion.SecretIdentifier.Identifier, newVersion.Attributes); + } + + throw new LunaDbSaveException(e.InnerException.Message, e); + } return versionDb; } @@ -423,29 +491,70 @@ public async Task DeleteAsync(string productName, string deploymentN version.ProductName = productName; version.DeploymentName = deploymentName; - // delete athentication key from keyVault if authentication type is key + SecretBundle currentVersionAuthenticationKey = new SecretBundle(); + SecretBundle currentVersionGitPersonalAccessToken = new SecretBundle(); + + // Disable athentication key from keyVault if authentication type is key if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) { - if (version.AuthenticationKey != null) + if (!string.IsNullOrEmpty(version.AuthenticationKeySecretName)) { - string secretName = version.AuthenticationKeySecretName; - try - { - await (_keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, secretName)); - } - catch - { - } + // Disable current version secret + currentVersionAuthenticationKey = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, version.AuthenticationKeySecretName); + await _keyVaultHelper.DisableVersionAsync(currentVersionAuthenticationKey.SecretIdentifier.Identifier, currentVersionAuthenticationKey.Attributes); } } + //Disable GitPersonalAccessToken + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + currentVersionGitPersonalAccessToken = await _keyVaultHelper.GetSecretVersionsAsync(_options.CurrentValue.Config.VaultName, version.GitPersonalAccessTokenSecretName); + await _keyVaultHelper.DisableVersionAsync(currentVersionGitPersonalAccessToken.SecretIdentifier.Identifier, currentVersionGitPersonalAccessToken.Attributes); + } + // Remove the apiVersion from the APIM await _apiVersionAPIM.DeleteAsync(version); // Remove the apiVersion from the db - _context.APIVersions.Remove(version); - await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(APIVersion).Name, versionName)); + try + { + _context.APIVersions.Remove(version); + await _context._SaveChangesAsync(); + + // Delete secret from key vault + if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) + { + if (!string.IsNullOrEmpty(version.AuthenticationKeySecretName)) + { + await _keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, version.AuthenticationKeySecretName); + } + } + + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + await _keyVaultHelper.DeleteSecretAsync(_options.CurrentValue.Config.VaultName, version.GitPersonalAccessTokenSecretName); + } + + _logger.LogInformation(LoggingUtils.ComposeResourceDeletedMessage(typeof(APIVersion).Name, versionName)); + } + catch (Exception e) + { + // Enable current version secret + if (version.AuthenticationType.Equals("Key", StringComparison.InvariantCultureIgnoreCase)) + { + if (!string.IsNullOrEmpty(version.AuthenticationKeySecretName)) + { + await _keyVaultHelper.EnableVersionAsync(currentVersionAuthenticationKey.SecretIdentifier.Identifier, currentVersionAuthenticationKey.Attributes); + } + } + + if (!string.IsNullOrEmpty(version.GitPersonalAccessToken)) + { + await _keyVaultHelper.EnableVersionAsync(currentVersionGitPersonalAccessToken.SecretIdentifier.Identifier, currentVersionGitPersonalAccessToken.Attributes); + } + + throw new LunaDbSaveException(e.InnerException.Message, e); + } return version; } diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/DeploymentService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/DeploymentService.cs index 81257fc..019b74c 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/DeploymentService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/DeploymentService.cs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -using Luna.Clients.Azure; using Luna.Clients.Azure.APIM; using Luna.Clients.Exceptions; using Luna.Clients.Logging; +using Luna.Clients.Controller; using Luna.Data.Entities; using Luna.Data.Repository; using Luna.Services.Utilities.ExpressionEvaluation; @@ -115,6 +115,13 @@ public async Task CreateAsync(string productName, Deployment deploym UserErrorCode.PayloadNotProvided); } + // Check if DeploymentName is valid + if (await ControllerHelper.CheckNameValidity(deployment.DeploymentName, nameof(Deployment))) + { + throw new LunaBadRequestUserException(LoggingUtils.ComposeNameInvalidErrorMessage(nameof(Deployment), deployment.DeploymentName), + UserErrorCode.PayloadNameInvalid); + } + // Check that the deployment does not already have an DeploymentName with the same productName if (await ExistsAsync(productName, deployment.DeploymentName)) { diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/ProductService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/ProductService.cs index dcc0968..dcfeac3 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/ProductService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/ProductService.cs @@ -4,6 +4,7 @@ using Luna.Clients.Azure.APIM; using Luna.Clients.Exceptions; using Luna.Clients.Logging; +using Luna.Clients.Controller; using Luna.Data.Entities; using Luna.Data.Enums; using Luna.Data.Repository; @@ -72,6 +73,13 @@ public async Task CreateAsync(Product product) UserErrorCode.PayloadNotProvided); } + // Check if ProductName is valid + if (await ControllerHelper.CheckNameValidity(product.ProductName, nameof(Product))) + { + throw new LunaBadRequestUserException(LoggingUtils.ComposeNameInvalidErrorMessage(nameof(Product), product.ProductName), + UserErrorCode.PayloadNameInvalid); + } + // Check that an offer with the same name does not already exist if (await ExistsAsync(product.ProductName)) { @@ -91,7 +99,7 @@ public async Task CreateAsync(Product product) // Add product to db _context.Products.Add(product); await _context._SaveChangesAsync(); - _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(Offer).Name, product.ProductName)); + _logger.LogInformation(LoggingUtils.ComposeResourceCreatedMessage(typeof(Product).Name, product.ProductName)); return product; } From 27c1b38dbc0ee07700c770e00561c73973fd56fe Mon Sep 17 00:00:00 2001 From: Yuhan Yao Date: Mon, 31 Aug 2020 09:34:31 +0800 Subject: [PATCH 2/2] fix some naming problems --- .../APIRouting/APIRoutingController.cs | 30 ++++++------ .../Admin/Luna.AI/APIVersionController.cs | 2 +- .../Admin/Luna.AI/DeploymentController.cs | 20 +++++--- .../Azure/APIM/Luna.AI/OperationAPIM.cs | 44 ++++++++--------- .../Azure/APIM/Luna.AI/PolicyAPIM.cs | 38 +++++++-------- .../Controller/ControllerHelper.cs | 48 +++++++++---------- .../Azure/APIM/Luna.AI/OperationTypeEnum.cs | 14 +++--- .../GetABatchInferenceOperationRequest.cs | 2 +- .../GetABatchInferenceOperationResponse.cs | 4 +- ...ADeployOperationByEndpointIdUserRequest.cs | 2 +- ...DeployOperationByEndpointIdUserResponse.cs | 4 +- ...lByModelIdUserProductDeploymentResponse.cs | 2 +- ...pointIdUserProductAndDeploymentResponse.cs | 6 +-- ...lTrainingOperationsByModelIdUserRequest.cs | 4 +- ...TrainingOperationsByModelIdUserResponse.cs | 4 +- .../GetABatchInferenceOperationResponse.cs | 2 +- ...DeployOperationByEndpointIdUserResponse.cs | 2 +- ...lByModelIdUserProductDeploymentResponse.cs | 2 +- ...pointIdUserProductAndDeploymentResponse.cs | 2 +- ...TrainingOperationsByModelIdUserResponse.cs | 2 +- .../Data/Luna.AI/APIVersionService.cs | 14 +++--- 21 files changed, 127 insertions(+), 121 deletions(-) diff --git a/end-to-end-solutions/Luna/src/Luna.API/Controllers/APIRouting/APIRoutingController.cs b/end-to-end-solutions/Luna/src/Luna.API/Controllers/APIRouting/APIRoutingController.cs index dd6c3ce..91bc1a4 100644 --- a/end-to-end-solutions/Luna/src/Luna.API/Controllers/APIRouting/APIRoutingController.cs +++ b/end-to-end-solutions/Luna/src/Luna.API/Controllers/APIRouting/APIRoutingController.cs @@ -105,7 +105,7 @@ public async Task BatchInferenceWithDefaultModel(string productNam [HttpGet("products/{productName}/deployments/{deploymentName}/operations/{operationId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetABatchInferenceOperationWithDefaultModel(string productName, string deploymentName, Guid operationId, [FromQuery(Name = "api-version")] string versionName, [FromBody] BatchInferenceRequest request) + public async Task GetBatchInferenceOperationWithDefaultModel(string productName, string deploymentName, Guid operationId, [FromQuery(Name = "api-version")] string versionName, [FromBody] BatchInferenceRequest request) { var apiSubcription = await _apiSubscriptionService.GetAsync(request.subscriptionId); if (apiSubcription == null) @@ -122,7 +122,7 @@ public async Task GetABatchInferenceOperationWithDefaultModel(stri - return Ok(await ControllerHelper.GetABatchInferenceOperationWithDefaultModel(product, deployment, version, workspace, apiSubcription, operationId)); + return Ok(await ControllerHelper.GetBatchInferenceOperationWithDefaultModel(product, deployment, version, workspace, apiSubcription, operationId)); } [HttpGet("products/{productName}/deployments/{deploymentName}/operations")] @@ -171,7 +171,7 @@ public async Task TrainModel(string productName, string deployment [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/training/{modelId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetATrainingOperationsByModelIdUser(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task GetTrainingOperationByModelIdUser(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -189,7 +189,7 @@ public async Task GetATrainingOperationsByModelIdUser(string produ - return Ok(await ControllerHelper.GetATrainingOperationsByModelIdUser(product, deployment, version, workspace, apiSubcription, modelId)); + return Ok(await ControllerHelper.GetTrainingOperationByModelIdUser(product, deployment, version, workspace, apiSubcription, modelId)); } [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/training")] @@ -216,7 +216,7 @@ public async Task ListAllTrainingOperationsByUser(string productNa [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/models/{modelId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetAModelByModelIdUserProductDeployment(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task GetModelByModelIdUserProductDeployment(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -233,7 +233,7 @@ public async Task GetAModelByModelIdUserProductDeployment(string p - return Ok(await ControllerHelper.GetAModelByModelIdUserProductDeployment(product, deployment, version, workspace, apiSubcription, modelId)); + return Ok(await ControllerHelper.GetModelByModelIdUserProductDeployment(product, deployment, version, workspace, apiSubcription, modelId)); } [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/models")] @@ -260,7 +260,7 @@ public async Task GetAllModelsByUserProductDeployment(string produ [HttpDelete("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/models/{modelId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task DeleteAModel(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task DeleteModel(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -274,7 +274,7 @@ public async Task DeleteAModel(string productName, string deployme var workspace = await _amlWorkspaceService.GetAsync(version.AMLWorkspaceName); - await ControllerHelper.DeleteAModel(workspace, modelId); + await ControllerHelper.DeleteModel(workspace, modelId); return Ok(); } @@ -301,7 +301,7 @@ public async Task BatchInference(string productName, string deploy [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/inference/{operationId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetABatchInferenceOperation(string productName, string deploymentName, Guid subscriptionId, Guid operationId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task GetBatchInferenceOperation(string productName, string deploymentName, Guid subscriptionId, Guid operationId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -318,7 +318,7 @@ public async Task GetABatchInferenceOperation(string productName, - return Ok(await ControllerHelper.GetABatchInferenceOperation(product, deployment, version, workspace, apiSubcription, operationId)); + return Ok(await ControllerHelper.GetBatchInferenceOperation(product, deployment, version, workspace, apiSubcription, operationId)); } [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/inference")] @@ -367,7 +367,7 @@ public async Task DeployRealTimePredictionEndpoint(string productN [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/deployment/{endpointId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetADeployOperationByEndpointIdUser(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task GetDeployOperationByEndpointIdUser(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -384,7 +384,7 @@ public async Task GetADeployOperationByEndpointIdUser(string produ - return Ok(await ControllerHelper.GetADeployOperationByEndpointIdUser(product, deployment, version, workspace, apiSubcription, endpointId)); + return Ok(await ControllerHelper.GetDeployOperationByEndpointIdUser(product, deployment, version, workspace, apiSubcription, endpointId)); } [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/deployment")] @@ -433,7 +433,7 @@ public async Task GetAllRealTimeServiceEndpointsByUserProductAndDe [HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/endpoints/{endpointId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task GetARealTimeServiceEndpointByEndpointIdUserProductAndDeployment(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task GetRealTimeServiceEndpointByEndpointIdUserProductAndDeployment(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -456,7 +456,7 @@ public async Task GetARealTimeServiceEndpointByEndpointIdUserProdu [HttpDelete("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/endpoints/{endpointId}")] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task DeleteAEndpoint(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) + public async Task DeleteEndpoint(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName) { var apiSubcription = await _apiSubscriptionService.GetAsync(subscriptionId); if (apiSubcription == null) @@ -471,7 +471,7 @@ public async Task DeleteAEndpoint(string productName, string deplo - await ControllerHelper.DeleteAEndpoint(workspace, endpointId); + await ControllerHelper.DeleteEndpoint(workspace, endpointId); return Ok(); } diff --git a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs index 22192d9..81a5dce 100644 --- a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs +++ b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/APIVersionController.cs @@ -108,7 +108,7 @@ public async Task CreateOrUpdateAsync(string productName, string d else { _logger.LogInformation($"Create apiVersion {versionName} in deployment {deploymentName} in product {productName}."); - await _apiVersionService.CreateAsync(productName, deploymentName, apiVersion); + apiVersion = await _apiVersionService.CreateAsync(productName, deploymentName, apiVersion); return CreatedAtRoute(nameof(GetAsync) + nameof(APIVersion), new { productName = productName, deploymentName = deploymentName, versionName = versionName }, apiVersion); } diff --git a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/DeploymentController.cs b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/DeploymentController.cs index 435011f..54591b7 100644 --- a/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/DeploymentController.cs +++ b/end-to-end-solutions/Luna/src/Luna.API/Controllers/Admin/Luna.AI/DeploymentController.cs @@ -28,18 +28,18 @@ public class DeploymentController : ControllerBase { private readonly IDeploymentService _deploymentService; private readonly ILogger _logger; - private readonly IAPIVersionService _apiVersionService; + private readonly IAPISubscriptionService _apiSubscriptionService; /// /// Constructor that uses dependency injection. /// /// The service to inject. /// The logger. - public DeploymentController(IDeploymentService deploymentService, ILogger logger, IAPIVersionService apiVersionService) + public DeploymentController(IDeploymentService deploymentService, ILogger logger, IAPISubscriptionService apiSubscriptionService) { _deploymentService = deploymentService ?? throw new ArgumentNullException(nameof(deploymentService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _apiVersionService = apiVersionService ?? throw new ArgumentNullException(nameof(apiVersionService)); + _apiSubscriptionService = apiSubscriptionService ?? throw new ArgumentNullException(nameof(apiSubscriptionService)); } /// @@ -122,11 +122,17 @@ public async Task DeleteAsync(string productName, string deploymen AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true); _logger.LogInformation($"Delete deployment {deploymentName} from product {productName}."); - // check if there exist apiversions - var apiVersions = await _apiVersionService.GetAllAsync(productName, deploymentName); - if (apiVersions.Count != 0) + // check if there exist api subscriptions + var apiSubscriptions = await _apiSubscriptionService.GetAllAsync(); + if (apiSubscriptions.Count != 0) { - throw new LunaConflictUserException($"Unable to delete {deploymentName} with subscription"); + foreach (var apiSubscription in apiSubscriptions) + { + if (apiSubscription.ProductName.Equals(productName, StringComparison.InvariantCultureIgnoreCase) && apiSubscription.DeploymentName.Equals(deploymentName, StringComparison.InvariantCultureIgnoreCase)) + { + throw new LunaConflictUserException($"Unable to delete {deploymentName} with subscription"); + } + } } await _deploymentService.DeleteAsync(productName, deploymentName); diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/OperationAPIM.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/OperationAPIM.cs index c345aff..afbab69 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/OperationAPIM.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/OperationAPIM.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -73,7 +73,7 @@ private Models.Azure.Operation BatchInferenceWithDefaultModel() return operation; } - private Models.Azure.Operation GetABatchInferenceOperationWithDefaultModel() + private Models.Azure.Operation GetBatchInferenceOperationWithDefaultModel() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -125,7 +125,7 @@ private Models.Azure.Operation ListAllTrainingOperationsByUser() return operation; } - private Models.Azure.Operation GetATrainingOperationsByModelIdUser() + private Models.Azure.Operation GetTrainingOperationByModelIdUser() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -141,7 +141,7 @@ private Models.Azure.Operation GetATrainingOperationsByModelIdUser() return operation; } - private Models.Azure.Operation GetAModelByModelIdUserProductDeployment() + private Models.Azure.Operation GetModelByModelIdUserProductDeployment() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -169,7 +169,7 @@ private Models.Azure.Operation GetAllModelsByUserProductDeployment() return operation; } - private Models.Azure.Operation DeleteAModel() + private Models.Azure.Operation DeleteModel() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -201,7 +201,7 @@ private Models.Azure.Operation BatchInference() return operation; } - private Models.Azure.Operation GetABatchInferenceOperation() + private Models.Azure.Operation GetBatchInferenceOperation() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -245,7 +245,7 @@ private Models.Azure.Operation DeployRealTimePredictionEndpoint() return operation; } - private Models.Azure.Operation GetADeployOperationByEndpointIdUser() + private Models.Azure.Operation GetDeployOperationByEndpointIdUser() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -301,7 +301,7 @@ private Models.Azure.Operation GetARealTimeServiceEndpointByEndpointIdUserProduc return operation; } - private Models.Azure.Operation DeleteAEndpoint() + private Models.Azure.Operation DeleteEndpoint() { Models.Azure.Operation operation = new Models.Azure.Operation(); @@ -344,40 +344,40 @@ public Models.Azure.Operation GetOperation(Models.Azure.OperationTypeEnum operat return RealTimePrediction(); case Models.Azure.OperationTypeEnum.BatchInferenceWithDefaultModel: return BatchInferenceWithDefaultModel(); - case Models.Azure.OperationTypeEnum.GetABatchInferenceOperationWithDefaultModel: - return GetABatchInferenceOperationWithDefaultModel(); + case Models.Azure.OperationTypeEnum.GetBatchInferenceOperationWithDefaultModel: + return GetBatchInferenceOperationWithDefaultModel(); case Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUserWithDefaultModel: return ListAllInferenceOperationsByUserWithDefaultModel(); case Models.Azure.OperationTypeEnum.TrainModel: return TrainModel(); case Models.Azure.OperationTypeEnum.ListAllTrainingOperationsByUser: return ListAllTrainingOperationsByUser(); - case Models.Azure.OperationTypeEnum.GetATrainingOperationsByModelIdUser: - return GetATrainingOperationsByModelIdUser(); - case Models.Azure.OperationTypeEnum.GetAModelByModelIdUserProductDeployment: - return GetAModelByModelIdUserProductDeployment(); + case Models.Azure.OperationTypeEnum.GetTrainingOperationByModelIdUser: + return GetTrainingOperationByModelIdUser(); + case Models.Azure.OperationTypeEnum.GetModelByModelIdUserProductDeployment: + return GetModelByModelIdUserProductDeployment(); case Models.Azure.OperationTypeEnum.GetAllModelsByUserProductDeployment: return GetAllModelsByUserProductDeployment(); - case Models.Azure.OperationTypeEnum.DeleteAModel: - return DeleteAModel(); + case Models.Azure.OperationTypeEnum.DeleteModel: + return DeleteModel(); case Models.Azure.OperationTypeEnum.BatchInference: return BatchInference(); - case Models.Azure.OperationTypeEnum.GetABatchInferenceOperation: - return GetABatchInferenceOperation(); + case Models.Azure.OperationTypeEnum.GetBatchInferenceOperation: + return GetBatchInferenceOperation(); case Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUser: return ListAllInferenceOperationsByUser(); case Models.Azure.OperationTypeEnum.DeployRealTimePredictionEndpoint: return DeployRealTimePredictionEndpoint(); - case Models.Azure.OperationTypeEnum.GetADeployOperationByEndpointIdUser: - return GetADeployOperationByEndpointIdUser(); + case Models.Azure.OperationTypeEnum.GetDeployOperationByEndpointIdUser: + return GetDeployOperationByEndpointIdUser(); case Models.Azure.OperationTypeEnum.ListAllDeployOperationsByUser: return ListAllDeployOperationsByUser(); case Models.Azure.OperationTypeEnum.GetAllRealTimeServiceEndpointsByUserProductDeployment: return GetAllRealTimeServiceEndpointsByUserProductDeployment(); case Models.Azure.OperationTypeEnum.GetARealTimeServiceEndpointByEndpointIdUserProductDeployment: return GetARealTimeServiceEndpointByEndpointIdUserProductDeployment(); - case Models.Azure.OperationTypeEnum.DeleteAEndpoint: - return DeleteAEndpoint(); + case Models.Azure.OperationTypeEnum.DeleteEndpoint: + return DeleteEndpoint(); default: throw new LunaServerException($"Invalid operation type. The type is {nameof(operationType)}."); } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/PolicyAPIM.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/PolicyAPIM.cs index 74815a5..1dbd62f 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/PolicyAPIM.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Azure/APIM/Luna.AI/PolicyAPIM.cs @@ -134,7 +134,7 @@ private Models.Azure.Policy BatchInferenceWithDefaultModel(APIVersion version) return policy; } - private Models.Azure.Policy GetABatchInferenceOperationWithDefaultModel(APIVersion version) + private Models.Azure.Policy GetBatchInferenceOperationWithDefaultModel(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -259,7 +259,7 @@ private Models.Azure.Policy ListAllTrainingOperationsByUser(APIVersion version) return policy; } - private Models.Azure.Policy GetATrainingOperationsByModelIdUser(APIVersion version) + private Models.Azure.Policy GetTrainingOperationByModelIdUser(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -289,7 +289,7 @@ private Models.Azure.Policy GetATrainingOperationsByModelIdUser(APIVersion versi return policy; } - private Models.Azure.Policy GetAModelByModelIdUserProductDeployment(APIVersion version) + private Models.Azure.Policy GetModelByModelIdUserProductDeployment(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -349,7 +349,7 @@ private Models.Azure.Policy GetAllModelsByUserProductDeployment(APIVersion versi return policy; } - private Models.Azure.Policy DeleteAModel(APIVersion version) + private Models.Azure.Policy DeleteModel(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -414,7 +414,7 @@ private Models.Azure.Policy BatchInference(APIVersion version) return policy; } - private Models.Azure.Policy GetABatchInferenceOperation(APIVersion version) + private Models.Azure.Policy GetBatchInferenceOperation(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -629,7 +629,7 @@ private Models.Azure.Policy GetARealTimeServiceEndpointByEndpointIdUserProductDe return policy; } - private Models.Azure.Policy DeleteAEndpoint(APIVersion version) + private Models.Azure.Policy DeleteEndpoint(APIVersion version) { Models.Azure.Policy policy = new Models.Azure.Policy(); string backendUrl = _controllerBaseUrl + string.Format("/api/products/{0}/deployments/{1}", version.ProductName, version.DeploymentName) + "/subscriptions/{0}"; @@ -667,31 +667,31 @@ private Models.Azure.Policy GetPolicy(APIVersion version, Models.Azure.Operation return RealTimePrediction(version); case Models.Azure.OperationTypeEnum.BatchInferenceWithDefaultModel: return BatchInferenceWithDefaultModel(version); - case Models.Azure.OperationTypeEnum.GetABatchInferenceOperationWithDefaultModel: - return GetABatchInferenceOperationWithDefaultModel(version); + case Models.Azure.OperationTypeEnum.GetBatchInferenceOperationWithDefaultModel: + return GetBatchInferenceOperationWithDefaultModel(version); case Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUserWithDefaultModel: return ListAllInferenceOperationsByUserWithDefaultModel(version); case Models.Azure.OperationTypeEnum.TrainModel: return TrainModel(version); case Models.Azure.OperationTypeEnum.ListAllTrainingOperationsByUser: return ListAllTrainingOperationsByUser(version); - case Models.Azure.OperationTypeEnum.GetATrainingOperationsByModelIdUser: - return GetATrainingOperationsByModelIdUser(version); - case Models.Azure.OperationTypeEnum.GetAModelByModelIdUserProductDeployment: - return GetAModelByModelIdUserProductDeployment(version); + case Models.Azure.OperationTypeEnum.GetTrainingOperationByModelIdUser: + return GetTrainingOperationByModelIdUser(version); + case Models.Azure.OperationTypeEnum.GetModelByModelIdUserProductDeployment: + return GetModelByModelIdUserProductDeployment(version); case Models.Azure.OperationTypeEnum.GetAllModelsByUserProductDeployment: return GetAllModelsByUserProductDeployment(version); - case Models.Azure.OperationTypeEnum.DeleteAModel: - return DeleteAModel(version); + case Models.Azure.OperationTypeEnum.DeleteModel: + return DeleteModel(version); case Models.Azure.OperationTypeEnum.BatchInference: return BatchInference(version); - case Models.Azure.OperationTypeEnum.GetABatchInferenceOperation: - return GetABatchInferenceOperation(version); + case Models.Azure.OperationTypeEnum.GetBatchInferenceOperation: + return GetBatchInferenceOperation(version); case Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUser: return ListAllInferenceOperationsByUser(version); case Models.Azure.OperationTypeEnum.DeployRealTimePredictionEndpoint: return DeployRealTimePredictionEndpoint(version); - case Models.Azure.OperationTypeEnum.GetADeployOperationByEndpointIdUser: + case Models.Azure.OperationTypeEnum.GetDeployOperationByEndpointIdUser: return GetAllDeployOperationsByEndpointIdUser(version); case Models.Azure.OperationTypeEnum.ListAllDeployOperationsByUser: return ListAllDeployOperationsByUser(version); @@ -699,8 +699,8 @@ private Models.Azure.Policy GetPolicy(APIVersion version, Models.Azure.Operation return GetAllRealTimeServiceEndpointsByUserProductDeployment(version); case Models.Azure.OperationTypeEnum.GetARealTimeServiceEndpointByEndpointIdUserProductDeployment: return GetARealTimeServiceEndpointByEndpointIdUserProductDeployment(version); - case Models.Azure.OperationTypeEnum.DeleteAEndpoint: - return DeleteAEndpoint(version); + case Models.Azure.OperationTypeEnum.DeleteEndpoint: + return DeleteEndpoint(version); default: throw new LunaServerException($"Invalid operation type. The type is {nameof(operationType)}."); } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs index 8a98d59..254d484 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Controller/ControllerHelper.cs @@ -147,7 +147,7 @@ public static async Task BatchInferenceWithDefaultModel( return new BatchInferenceResponse { operationId = batchInferenceId }; } - public static async Task GetABatchInferenceOperationWithDefaultModel(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid operationId) + public static async Task GetBatchInferenceOperationWithDefaultModel(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid operationId) { var region = await GetRegion(workspace); @@ -158,7 +158,7 @@ public static async Task BatchInferenceWithDefaultModel( var token = await ControllerAuthHelper.GetToken(workspace.AADTenantId.ToString(), workspace.AADApplicationId.ToString(), workspace.AADApplicationSecrets); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - var getABatchInferenceOperationRequest = new Models.Controller.Backend.GetABatchInferenceOperationRequest(); + var getABatchInferenceOperationRequest = new Models.Controller.Backend.GetBatchInferenceOperationRequest(); getABatchInferenceOperationRequest.filter = $"runType eq azureml.PipelineRun and tags/operationType eq inference and tags/userId eq {apiSubscription.UserId} and tags/subscriptionId eq {apiSubscription.SubscriptionId} and tags/operationId eq {operationId.ToString("N")}"; request.Content = new StringContent(JsonConvert.SerializeObject(getABatchInferenceOperationRequest)); @@ -178,14 +178,14 @@ public static async Task BatchInferenceWithDefaultModel( throw new LunaServerException($"Query failed with response {responseContent}"); } - List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (operations == null || operations.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); } var operation = operations[0]; - Models.Controller.GetABatchInferenceOperationResponse getABatchInferenceOperationResponse = new Models.Controller.GetABatchInferenceOperationResponse() + Models.Controller.GetBatchInferenceOperationResponse getABatchInferenceOperationResponse = new Models.Controller.GetBatchInferenceOperationResponse() { operationId = operation.tags.operationId, status = operation.status, @@ -342,7 +342,7 @@ public static async Task TrainModel(Product product, Deploym return listAllTrainingOperationsByUserResponse; } - public static async Task GetATrainingOperationsByModelIdUser(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid modelId) + public static async Task GetTrainingOperationByModelIdUser(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid modelId) { var region = await GetRegion(workspace); @@ -353,7 +353,7 @@ public static async Task TrainModel(Product product, Deploym var token = await ControllerAuthHelper.GetToken(workspace.AADTenantId.ToString(), workspace.AADApplicationId.ToString(), workspace.AADApplicationSecrets); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - var getAllTrainingOperationsByModelIdUserRequest = new Models.Controller.Backend.GetATrainingOperationsByModelIdUserRequest(); + var getAllTrainingOperationsByModelIdUserRequest = new Models.Controller.Backend.GetTrainingOperationByModelIdUserRequest(); getAllTrainingOperationsByModelIdUserRequest.filter = $"tags/operationType eq training and runType eq azureml.PipelineRun and tags/userId eq {apiSubscription.UserId} and tags/subscriptionId eq {apiSubscription.SubscriptionId} and tags/modelId eq {modelId.ToString("N")}"; request.Content = new StringContent(JsonConvert.SerializeObject(getAllTrainingOperationsByModelIdUserRequest)); @@ -373,13 +373,13 @@ public static async Task TrainModel(Product product, Deploym throw new LunaServerException($"Query failed with response {responseContent}"); } - List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (operations == null || operations.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); } - Models.Controller.GetATrainingOperationsByModelIdUserResponse getATrainingOperationsByModelIdUserResponse = new Models.Controller.GetATrainingOperationsByModelIdUserResponse() + Models.Controller.GetTrainingOperationByModelIdUserResponse getATrainingOperationsByModelIdUserResponse = new Models.Controller.GetTrainingOperationByModelIdUserResponse() { operationType = operations[0].tags.operationType, modelId = operations[0].tags.modelId, @@ -393,7 +393,7 @@ public static async Task TrainModel(Product product, Deploym return getATrainingOperationsByModelIdUserResponse; } - public static async Task GetAModelByModelIdUserProductDeployment(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid modelId) + public static async Task GetModelByModelIdUserProductDeployment(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid modelId) { var region = await GetRegion(workspace); @@ -418,13 +418,13 @@ public static async Task TrainModel(Product product, Deploym throw new LunaServerException($"Query failed with response {responseContent}"); } - List models = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List models = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (models == null || models.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); } - Models.Controller.GetAModelByModelIdUserProductDeploymentResponse getAModelByModelIdUserProductDeploymentResponse = new Models.Controller.GetAModelByModelIdUserProductDeploymentResponse() + Models.Controller.GetModelByModelIdUserProductDeploymentResponse getAModelByModelIdUserProductDeploymentResponse = new Models.Controller.GetModelByModelIdUserProductDeploymentResponse() { modelId = models[0].name, startTimeUtc = models[0].createdTime, @@ -480,7 +480,7 @@ public static async Task TrainModel(Product product, Deploym return results; } - public static async Task DeleteAModel(AMLWorkspace workspace, Guid modelId) + public static async Task DeleteModel(AMLWorkspace workspace, Guid modelId) { var region = await GetRegion(workspace); @@ -535,7 +535,7 @@ public static async Task BatchInference(Product product, return new BatchInferenceResponse { operationId = operationId }; } - public static async Task GetABatchInferenceOperation(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid operationId) + public static async Task GetBatchInferenceOperation(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid operationId) { var region = await GetRegion(workspace); @@ -546,7 +546,7 @@ public static async Task BatchInference(Product product, var token = await ControllerAuthHelper.GetToken(workspace.AADTenantId.ToString(), workspace.AADApplicationId.ToString(), workspace.AADApplicationSecrets); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - var getABatchInferenceOperationRequest = new Models.Controller.Backend.GetABatchInferenceOperationRequest(); + var getABatchInferenceOperationRequest = new Models.Controller.Backend.GetBatchInferenceOperationRequest(); getABatchInferenceOperationRequest.filter = $"runType eq azureml.PipelineRun and tags/operationType eq inference and tags/userId eq {apiSubscription.UserId} and tags/subscriptionId eq {apiSubscription.SubscriptionId} and tags/operationId eq {operationId.ToString("N")}"; request.Content = new StringContent(JsonConvert.SerializeObject(getABatchInferenceOperationRequest)); @@ -566,13 +566,13 @@ public static async Task BatchInference(Product product, throw new LunaServerException($"Query failed with response {responseContent}"); } - List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List operations = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (operations == null || operations.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); } - Models.Controller.GetABatchInferenceOperationResponse getABatchInferenceOperationResponse = new Models.Controller.GetABatchInferenceOperationResponse() + Models.Controller.GetBatchInferenceOperationResponse getABatchInferenceOperationResponse = new Models.Controller.GetBatchInferenceOperationResponse() { operationId = operations[0].tags.operationId, operationType = operations[0].tags.operationType, @@ -681,7 +681,7 @@ public static async Task BatchInference(Product product, return new Models.Controller.DeployRealTimePredictionEndpointResponse { endpointId = endpointId }; } - public static async Task GetADeployOperationByEndpointIdUser(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid endpointId) + public static async Task GetDeployOperationByEndpointIdUser(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid endpointId) { var region = await GetRegion(workspace); @@ -692,7 +692,7 @@ public static async Task BatchInference(Product product, var token = await ControllerAuthHelper.GetToken(workspace.AADTenantId.ToString(), workspace.AADApplicationId.ToString(), workspace.AADApplicationSecrets); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); - var getAllDeployOperationsByEndpointIdUserRequest = new Models.Controller.Backend.GetADeployOperationByEndpointIdUserRequest(); + var getAllDeployOperationsByEndpointIdUserRequest = new Models.Controller.Backend.GetDeployOperationByEndpointIdUserRequest(); getAllDeployOperationsByEndpointIdUserRequest.filter = $"runType eq azureml.PipelineRun and tags/operationType eq deployment and tags/userId eq {apiSubscription.UserId} and tags/subscriptionId eq {apiSubscription.SubscriptionId} and tags/endpointId eq {endpointId.ToString("N")}"; request.Content = new StringContent(JsonConvert.SerializeObject(getAllDeployOperationsByEndpointIdUserRequest)); @@ -712,14 +712,14 @@ public static async Task BatchInference(Product product, throw new LunaServerException($"Query failed with response {responseContent}"); } - List endpoints = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List endpoints = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (endpoints == null || endpoints.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); } var endpoint = endpoints[0]; - Models.Controller.GetADeployOperationByEndpointIdUserResponse getAllDeployOperationsByEndpointIdAndVerifyUserResponse = new Models.Controller.GetADeployOperationByEndpointIdUserResponse() + Models.Controller.GetDeployOperationByEndpointIdUserResponse getAllDeployOperationsByEndpointIdAndVerifyUserResponse = new Models.Controller.GetDeployOperationByEndpointIdUserResponse() { operationType = endpoint.tags.operationType, endpointId = endpoint.tags.endpointId, @@ -862,7 +862,7 @@ public static async Task BatchInference(Product product, return getAllRealTimeServiceEndpointsByUserProductAndDeploymentResponse; } - public static async Task GetARealTimeServiceEndpointByEndpointIdUserProductDeployment(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid endpointId) + public static async Task GetARealTimeServiceEndpointByEndpointIdUserProductDeployment(Product product, Deployment deployment, APIVersion version, AMLWorkspace workspace, APISubscription apiSubscription, Guid endpointId) { var region = await GetRegion(workspace); @@ -887,7 +887,7 @@ public static async Task BatchInference(Product product, throw new LunaServerException($"Query failed with response {responseContent}"); } - List endpoints = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); + List endpoints = (List)System.Text.Json.JsonSerializer.Deserialize(result["value"].ToString(), typeof(List)); if (endpoints == null || endpoints.Count == 0) { throw new LunaServerException($"Query result in bad format. The response is {responseContent}."); @@ -895,7 +895,7 @@ public static async Task BatchInference(Product product, var endpoint = endpoints[0]; var getServiceKeysResponse = await GetServiceKeys(product, deployment, version, workspace, apiSubscription, new Guid(endpoint.name)); - Models.Controller.GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse getARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse = new Models.Controller.GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse() + Models.Controller.GetRealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse getARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse = new Models.Controller.GetRealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse() { endpointId = endpoint.name, startTimeUtc = endpoint.createdTime, @@ -908,7 +908,7 @@ public static async Task BatchInference(Product product, return getARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse; } - public static async Task DeleteAEndpoint(AMLWorkspace workspace, Guid endpointId) + public static async Task DeleteEndpoint(AMLWorkspace workspace, Guid endpointId) { var region = await GetRegion(workspace); diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Azure/APIM/Luna.AI/OperationTypeEnum.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Azure/APIM/Luna.AI/OperationTypeEnum.cs index 8afc301..e1606ab 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Azure/APIM/Luna.AI/OperationTypeEnum.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Azure/APIM/Luna.AI/OperationTypeEnum.cs @@ -13,23 +13,23 @@ public enum OperationTypeEnum RealTimePrediction, // BI BatchInferenceWithDefaultModel, - GetABatchInferenceOperationWithDefaultModel, + GetBatchInferenceOperationWithDefaultModel, ListAllInferenceOperationsByUserWithDefaultModel, // TYOM TrainModel, ListAllTrainingOperationsByUser, - GetATrainingOperationsByModelIdUser, - GetAModelByModelIdUserProductDeployment, + GetTrainingOperationByModelIdUser, + GetModelByModelIdUserProductDeployment, GetAllModelsByUserProductDeployment, - DeleteAModel, + DeleteModel, BatchInference, - GetABatchInferenceOperation, + GetBatchInferenceOperation, ListAllInferenceOperationsByUser, DeployRealTimePredictionEndpoint, - GetADeployOperationByEndpointIdUser, + GetDeployOperationByEndpointIdUser, ListAllDeployOperationsByUser, GetAllRealTimeServiceEndpointsByUserProductDeployment, GetARealTimeServiceEndpointByEndpointIdUserProductDeployment, - DeleteAEndpoint + DeleteEndpoint } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationRequest.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationRequest.cs index 5dc0486..5797ad7 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationRequest.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationRequest.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetABatchInferenceOperationRequest + public class GetBatchInferenceOperationRequest { public string filter { get; set; } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationResponse.cs index f3ea4d1..3b97b9e 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetABatchInferenceOperationResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetABatchInferenceOperationResponse + public class GetBatchInferenceOperationResponse { public string status { get; set; } public string startTimeUtc { get; set; } @@ -20,7 +20,7 @@ public class Tags public string operationId { get; set; } public string operationType { get; set; } } - public GetABatchInferenceOperationResponse() + public GetBatchInferenceOperationResponse() { this.tags = new Tags(); } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserRequest.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserRequest.cs index d5bcc20..9cd2115 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserRequest.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserRequest.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetADeployOperationByEndpointIdUserRequest + public class GetDeployOperationByEndpointIdUserRequest { public string filter { get; set; } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserResponse.cs index 0364949..b7e938b 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetADeployOperationByEndpointIdUserResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetADeployOperationByEndpointIdUserResponse + public class GetDeployOperationByEndpointIdUserResponse { public string status { get; set; } public string startTimeUtc { get; set; } @@ -19,7 +19,7 @@ public class Tags public string operationType { get; set; } public string endpointId { get; set; } } - public GetADeployOperationByEndpointIdUserResponse() + public GetDeployOperationByEndpointIdUserResponse() { } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAModelByModelIdUserProductDeploymentResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAModelByModelIdUserProductDeploymentResponse.cs index 0b272f3..6164a11 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAModelByModelIdUserProductDeploymentResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAModelByModelIdUserProductDeploymentResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetAModelByModelIdUserProductDeploymentResponse + public class GetModelByModelIdUserProductDeploymentResponse { public string name { get; set; } public string createdTime { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs index 1dc0656..a0c16d4 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -7,14 +7,14 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse + public class GetRealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse { public string name { get; set; } public string createdTime { get; set; } public string updatedTime { get; set; } public string scoringUri { get; set; } public String description { get; set; } - public GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse() + public GetRealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse() { } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserRequest.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserRequest.cs index 36b6aa1..936d4ef 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserRequest.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserRequest.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetATrainingOperationsByModelIdUserRequest + public class GetTrainingOperationByModelIdUserRequest { public string filter { get; set; } } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserResponse.cs index 5137d2a..9353675 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/Backend/GetAllTrainingOperationsByModelIdUserResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller.Backend { - public class GetATrainingOperationsByModelIdUserResponse + public class GetTrainingOperationByModelIdUserResponse { public string status { get; set; } public string startTimeUtc { get; set; } @@ -20,7 +20,7 @@ public class Tags public string modelId { get; set; } public string operationType { get; set; } } - public GetATrainingOperationsByModelIdUserResponse() + public GetTrainingOperationByModelIdUserResponse() { } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetABatchInferenceOperationResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetABatchInferenceOperationResponse.cs index f5d2e43..9c403fb 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetABatchInferenceOperationResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetABatchInferenceOperationResponse.cs @@ -8,7 +8,7 @@ namespace Luna.Clients.Models.Controller { - public class GetABatchInferenceOperationResponse + public class GetBatchInferenceOperationResponse { public string operationType { get; set; } public string operationId { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetADeployOperationByEndpointIdUserResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetADeployOperationByEndpointIdUserResponse.cs index cf38906..454a60f 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetADeployOperationByEndpointIdUserResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetADeployOperationByEndpointIdUserResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller { - public class GetADeployOperationByEndpointIdUserResponse + public class GetDeployOperationByEndpointIdUserResponse { public string operationType { get; set; } public string endpointId { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAModelByModelIdUserProductDeploymentResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAModelByModelIdUserProductDeploymentResponse.cs index 6ef4eeb..910be48 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAModelByModelIdUserProductDeploymentResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAModelByModelIdUserProductDeploymentResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller { - public class GetAModelByModelIdUserProductDeploymentResponse + public class GetModelByModelIdUserProductDeploymentResponse { public string modelId { get; set; } public string startTimeUtc { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs index 7ef8ec2..5cb119f 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller { - public class GetARealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse + public class GetRealTimeServiceEndpointByEndpointIdUserProductAndDeploymentResponse { public string endpointId { get; set; } public string startTimeUtc { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAllTrainingOperationsByModelIdUserResponse.cs b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAllTrainingOperationsByModelIdUserResponse.cs index 4b69b36..b53b532 100644 --- a/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAllTrainingOperationsByModelIdUserResponse.cs +++ b/end-to-end-solutions/Luna/src/Luna.Clients/Models/Controller/GetAllTrainingOperationsByModelIdUserResponse.cs @@ -7,7 +7,7 @@ namespace Luna.Clients.Models.Controller { - public class GetATrainingOperationsByModelIdUserResponse + public class GetTrainingOperationByModelIdUserResponse { public string operationType { get; set; } public string modelId { get; set; } diff --git a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs index 1ea6533..0da81e6 100644 --- a/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs +++ b/end-to-end-solutions/Luna/src/Luna.Services/Data/Luna.AI/APIVersionService.cs @@ -79,7 +79,7 @@ public APIVersionService(ISqlDbContext sqlDbContext, IProductService productServ case "BI": return new List{ Clients.Models.Azure.OperationTypeEnum.BatchInferenceWithDefaultModel, - Clients.Models.Azure.OperationTypeEnum.GetABatchInferenceOperationWithDefaultModel, + Clients.Models.Azure.OperationTypeEnum.GetBatchInferenceOperationWithDefaultModel, Clients.Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUserWithDefaultModel, }; // Train Your Own Model @@ -87,19 +87,19 @@ public APIVersionService(ISqlDbContext sqlDbContext, IProductService productServ return new List{ Clients.Models.Azure.OperationTypeEnum.TrainModel, Clients.Models.Azure.OperationTypeEnum.ListAllTrainingOperationsByUser, - Clients.Models.Azure.OperationTypeEnum.GetATrainingOperationsByModelIdUser, - Clients.Models.Azure.OperationTypeEnum.GetAModelByModelIdUserProductDeployment, + Clients.Models.Azure.OperationTypeEnum.GetTrainingOperationByModelIdUser, + Clients.Models.Azure.OperationTypeEnum.GetModelByModelIdUserProductDeployment, Clients.Models.Azure.OperationTypeEnum.GetAllModelsByUserProductDeployment, - Clients.Models.Azure.OperationTypeEnum.DeleteAModel, + Clients.Models.Azure.OperationTypeEnum.DeleteModel, Clients.Models.Azure.OperationTypeEnum.BatchInference, - Clients.Models.Azure.OperationTypeEnum.GetABatchInferenceOperation, + Clients.Models.Azure.OperationTypeEnum.GetBatchInferenceOperation, Clients.Models.Azure.OperationTypeEnum.ListAllInferenceOperationsByUser, Clients.Models.Azure.OperationTypeEnum.DeployRealTimePredictionEndpoint, - Clients.Models.Azure.OperationTypeEnum.GetADeployOperationByEndpointIdUser, + Clients.Models.Azure.OperationTypeEnum.GetDeployOperationByEndpointIdUser, Clients.Models.Azure.OperationTypeEnum.ListAllDeployOperationsByUser, Clients.Models.Azure.OperationTypeEnum.GetAllRealTimeServiceEndpointsByUserProductDeployment, Clients.Models.Azure.OperationTypeEnum.GetARealTimeServiceEndpointByEndpointIdUserProductDeployment, - Clients.Models.Azure.OperationTypeEnum.DeleteAEndpoint + Clients.Models.Azure.OperationTypeEnum.DeleteEndpoint }; default: throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(typeof(APIVersion).Name),