Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public async Task<ActionResult> BatchInferenceWithDefaultModel(string productNam

[HttpGet("products/{productName}/deployments/{deploymentName}/operations/{operationId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetABatchInferenceOperationWithDefaultModel(string productName, string deploymentName, Guid operationId, [FromQuery(Name = "api-version")] string versionName, [FromBody] BatchInferenceRequest request)
public async Task<ActionResult> 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)
Expand All @@ -122,7 +122,7 @@ public async Task<ActionResult> 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")]
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task<ActionResult> TrainModel(string productName, string deployment

[HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/training/{modelId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetATrainingOperationsByModelIdUser(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -189,7 +189,7 @@ public async Task<ActionResult> 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")]
Expand All @@ -216,7 +216,7 @@ public async Task<ActionResult> ListAllTrainingOperationsByUser(string productNa

[HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/models/{modelId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetAModelByModelIdUserProductDeployment(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -233,7 +233,7 @@ public async Task<ActionResult> 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")]
Expand All @@ -260,7 +260,7 @@ public async Task<ActionResult> GetAllModelsByUserProductDeployment(string produ

[HttpDelete("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/models/{modelId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> DeleteAModel(string productName, string deploymentName, Guid subscriptionId, Guid modelId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -274,7 +274,7 @@ public async Task<ActionResult> DeleteAModel(string productName, string deployme
var workspace = await _amlWorkspaceService.GetAsync(version.AMLWorkspaceName);


await ControllerHelper.DeleteAModel(workspace, modelId);
await ControllerHelper.DeleteModel(workspace, modelId);

return Ok();
}
Expand All @@ -301,7 +301,7 @@ public async Task<ActionResult> BatchInference(string productName, string deploy

[HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/inference/{operationId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetABatchInferenceOperation(string productName, string deploymentName, Guid subscriptionId, Guid operationId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -318,7 +318,7 @@ public async Task<ActionResult> 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")]
Expand Down Expand Up @@ -367,7 +367,7 @@ public async Task<ActionResult> DeployRealTimePredictionEndpoint(string productN

[HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/operations/deployment/{endpointId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetADeployOperationByEndpointIdUser(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -384,7 +384,7 @@ public async Task<ActionResult> 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")]
Expand Down Expand Up @@ -433,7 +433,7 @@ public async Task<ActionResult> GetAllRealTimeServiceEndpointsByUserProductAndDe

[HttpGet("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/endpoints/{endpointId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetARealTimeServiceEndpointByEndpointIdUserProductAndDeployment(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -456,7 +456,7 @@ public async Task<ActionResult> GetARealTimeServiceEndpointByEndpointIdUserProdu

[HttpDelete("products/{productName}/deployments/{deploymentName}/subscriptions/{subscriptionId}/endpoints/{endpointId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> DeleteAEndpoint(string productName, string deploymentName, Guid subscriptionId, Guid endpointId, [FromQuery(Name = "userid")] string userId, [FromQuery(Name = "api-version")] string versionName)
public async Task<ActionResult> 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)
Expand All @@ -471,7 +471,7 @@ public async Task<ActionResult> DeleteAEndpoint(string productName, string deplo



await ControllerHelper.DeleteAEndpoint(workspace, endpointId);
await ControllerHelper.DeleteEndpoint(workspace, endpointId);

return Ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -84,6 +86,13 @@ public async Task<ActionResult> GetAsync(string workspaceName)
return Ok(await _workspaceService.GetAsync(workspaceName));
}

public async Task<string> Test()
{
var azureServiceTokenProvider = new AzureServiceTokenProvider();
string test = azureServiceTokenProvider.KeyVaultTokenCallback.ToString();
return test;
}

/// <summary>
/// Creates or updates an workspace.
/// </summary>
Expand All @@ -95,7 +104,6 @@ public async Task<ActionResult> GetAsync(string workspaceName)
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> CreateOrUpdateAsync(string workspaceName, [FromBody] AMLWorkspace workspace)
{
AADAuthHelper.VerifyUserAccess(this.HttpContext, _logger, true);
if (workspace == null)
{
throw new LunaBadRequestUserException(LoggingUtils.ComposePayloadNotProvidedErrorMessage(nameof(workspace)), UserErrorCode.PayloadNotProvided);
Expand All @@ -109,13 +117,13 @@ public async Task<ActionResult> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ public async Task<ActionResult> 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)}.");
await _apiVersionService.CreateAsync(productName, deploymentName, apiVersion);
_logger.LogInformation($"Create apiVersion {versionName} in deployment {deploymentName} in product {productName}.");
apiVersion = await _apiVersionService.CreateAsync(productName, deploymentName, apiVersion);
return CreatedAtRoute(nameof(GetAsync) + nameof(APIVersion), new { productName = productName, deploymentName = deploymentName, versionName = versionName }, apiVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ public class DeploymentController : ControllerBase
{
private readonly IDeploymentService _deploymentService;
private readonly ILogger<RestrictedUserController> _logger;
private readonly IAPIVersionService _apiVersionService;
private readonly IAPISubscriptionService _apiSubscriptionService;

/// <summary>
/// Constructor that uses dependency injection.
/// </summary>
/// <param name="deploymentService">The service to inject.</param>
/// <param name="logger">The logger.</param>
public DeploymentController(IDeploymentService deploymentService, ILogger<RestrictedUserController> logger, IAPIVersionService apiVersionService)
public DeploymentController(IDeploymentService deploymentService, ILogger<RestrictedUserController> 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));
}

/// <summary>
Expand Down Expand Up @@ -122,11 +122,17 @@ public async Task<ActionResult> 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);
Expand Down
Loading