Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WOR-1296] Azure workspace quota endpoint #1508

Merged
merged 2 commits into from
Oct 30, 2023
Merged
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
10 changes: 8 additions & 2 deletions openapi/src/parts/azure_landing_zone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ paths:
parameters:
- $ref: '#/components/parameters/LandingZoneId'
get:
summary: List all Azure landing zones resources
deprecated: true
summary: |
List all Azure landing zones resources.
Deprecated in favor of the workspace-level landing zone resource endpoint.
operationId: listAzureLandingZoneResources
tags: [ LandingZones ]
responses:
Expand All @@ -161,7 +164,10 @@ paths:
- $ref: '#/components/parameters/LandingZoneId'
- $ref: '#/components/parameters/AzureResourceId'
get:
summary: Get the quota information of a resource an Azure Landing Zone
deprecated: true
summary: |
Get the quota information of a resource an Azure Landing Zone.
Deprecated in favor of the workspace-level landing zone resource endpoint.
operationId: getResourceQuotaResult
tags: [ LandingZones ]
responses:
Expand Down
35 changes: 35 additions & 0 deletions openapi/src/parts/controlled_azure_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
paths:
/api/workspaces/v1/{workspaceId}/resources/controlled/azure/landingzone:
parameters:
- $ref: '#/components/parameters/WorkspaceId'
get:
summary: List all Azure resources in an Azure workspace's backing landing zone.
operationId: listWorkspaceAzureLandingZoneResources
tags: [ ControlledAzureResource ]
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/AzureLandingZoneResourcesList'
'500':
$ref: '#/components/responses/ServerError'

/api/workspaces/v1/{workspaceId}/resources/controlled/azure/landingzone/quota:
parameters:
- $ref: '#/components/parameters/WorkspaceId'
- $ref: '#/components/parameters/AzureResourceId'
get:
summary: Get the quota information of a resource in an Azure workspace's backing landing zone.
operationId: getWorkspaceAzureLandingZoneResourceQuota
tags: [ ControlledAzureResource ]
responses:
'200':
$ref: '#/components/responses/ResourceQuotaResponse'
'400':
$ref: '#/components/responses/BadRequest'
'403':
$ref: '#/components/responses/PermissionDenied'
'500':
$ref: '#/components/responses/ServerError'
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import bio.terra.common.exception.ApiException;
import bio.terra.common.exception.ValidationException;
import bio.terra.common.iam.BearerToken;
import bio.terra.workspace.amalgam.landingzone.azure.LandingZoneApiDispatch;
import bio.terra.workspace.app.configuration.external.AzureConfiguration;
import bio.terra.workspace.app.configuration.external.FeatureConfiguration;
Expand All @@ -17,6 +18,7 @@
import bio.terra.workspace.generated.model.ApiAzureDatabaseResource;
import bio.terra.workspace.generated.model.ApiAzureDiskResource;
import bio.terra.workspace.generated.model.ApiAzureKubernetesNamespaceResource;
import bio.terra.workspace.generated.model.ApiAzureLandingZoneResourcesList;
import bio.terra.workspace.generated.model.ApiAzureManagedIdentityResource;
import bio.terra.workspace.generated.model.ApiAzureVmCreationParameters;
import bio.terra.workspace.generated.model.ApiAzureVmResource;
Expand All @@ -42,6 +44,7 @@
import bio.terra.workspace.generated.model.ApiDeleteControlledAzureResourceResult;
import bio.terra.workspace.generated.model.ApiJobControl;
import bio.terra.workspace.generated.model.ApiJobReport;
import bio.terra.workspace.generated.model.ApiResourceQuota;
import bio.terra.workspace.service.features.FeatureService;
import bio.terra.workspace.service.iam.AuthenticatedUserRequest;
import bio.terra.workspace.service.iam.AuthenticatedUserRequestFactory;
Expand Down Expand Up @@ -876,4 +879,37 @@ public ResponseEntity<ApiAzureKubernetesNamespaceResource> getAzureKubernetesNam
jobService.verifyUserAccess(jobId, userRequest, workspaceId);
return getJobDeleteResult(jobId);
}

@Override
public ResponseEntity<ApiResourceQuota> getWorkspaceAzureLandingZoneResourceQuota(
UUID workspaceId, String azureResourceId) {
features.azureEnabledCheck();

AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
var workspace =
workspaceService.validateWorkspaceAndAction(
userRequest, workspaceId, SamConstants.SamWorkspaceAction.WRITE);
var wsmToken = new BearerToken(samService.getWsmServiceAccountToken());
var landingZoneId = landingZoneApiDispatch.getLandingZoneId(wsmToken, workspace);

var result = landingZoneApiDispatch.getResourceQuota(wsmToken, landingZoneId, azureResourceId);

return new ResponseEntity<>(result, HttpStatus.OK);
}

@Override
public ResponseEntity<ApiAzureLandingZoneResourcesList> listWorkspaceAzureLandingZoneResources(
UUID workspaceId) {
features.azureEnabledCheck();

AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
var workspace =
workspaceService.validateWorkspaceAndAction(
userRequest, workspaceId, SamConstants.SamWorkspaceAction.WRITE);
var wsmToken = new BearerToken(samService.getWsmServiceAccountToken());
var landingZoneId = landingZoneApiDispatch.getLandingZoneId(wsmToken, workspace);

var result = landingZoneApiDispatch.listAzureLandingZoneResources(wsmToken, landingZoneId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
Loading