Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
CORTX-33950: GET IAM user capacity API with tenant as a path param (#894
Browse files Browse the repository at this point in the history
)

* CORTX-33950: IAM user capacity API with tenant as a path param

Signed-off-by: Rohit Kolapkar <rohit.j.kolapkar@seagate.com>

* CORTX-33950: IAM user capacity API with tenant as a path param

Signed-off-by: Rohit Kolapkar <rohit.j.kolapkar@seagate.com>

Signed-off-by: Rohit Kolapkar <rohit.j.kolapkar@seagate.com>
  • Loading branch information
Rohit Kolapkar authored Aug 25, 2022
1 parent f80f7d7 commit d2d3218
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions csm/core/controllers/storage_capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,33 @@ async def get(self):
with ServiceError.guard_service():
response = await self._service.get_usage(resource, resource_id)
return CsmResponse(response)


@CsmView._app_routes.view("/api/v2/capacity/s3/{tenant}/{resource}/{id}")
class S3CapacityTenantView(CsmView):
"""
GET REST API view implementation for getting capacity usage for specific user
"""

def __init__(self, request):
"""Get user level capacity usage Init."""
super().__init__(request)
self._service: S3CapacityService = self.request.app[const.S3_CAPACITY_SERVICE]

@CsmAuth.permissions({Resource.CAPACITY: {Action.LIST}})
@Log.trace_method(Log.DEBUG)
async def get(self):
resource = self.request.match_info[const.ARG_RESOURCE]
resource_id = self.request.match_info[const.ID]
tenant = self.request.match_info[const.TENANT]
resource_id = tenant+'$'+resource_id
Log.info(f"Handling GET s3 capacity request"
f"resource={resource} and id ={resource_id}")
try:
schema = S3CapacitySchema()
schema.load({const.ARG_RESOURCE:resource})
except ValidationError as val_err:
raise InvalidRequest(f"{ValidationErrorFormatter.format(val_err)}")
with ServiceError.guard_service():
response = await self._service.get_usage(resource, resource_id)
return CsmResponse(response)

0 comments on commit d2d3218

Please # to comment.