Commit a0e85010 authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Adding call to partition service for multi tenant

parent e12a936b
Pipeline #70086 passed with stage
in 49 seconds
......@@ -22,6 +22,10 @@ from import Tenant
import boto3
from datetime import datetime, timedelta, timezone
from botocore.exceptions import ClientError, WaiterError
from osdu_api.clients.partition_client import PartitionClient
from import PartitionInfoAws
import ujson as json
except ImportError:
......@@ -119,6 +123,10 @@ class AwsStorage(BlobStorageBase):
return UploadPolicy
def getTenantId(self, data_partition_id: str) -> str:
partition_client = PartitionClient(data_partition_id=data_partition_id)
partition_info_aws = partition_client.get_partition(data_partition_id)
return partition_info_aws.tenant_id
async def getCredentials(self, tenant: Tenant):
if len(self._session_token) > 2 and < self._timestamp:
......@@ -126,13 +134,13 @@ class AwsStorage(BlobStorageBase):
""" get credentials to access s3 bucket for tenant's folder """
# all tenants in one bucket(self._bucket_name). Each tenant.bucket_name is in fact, a folder in self._bucket_name
folder = tenant.bucket_name
data_partition_id = tenant.data_partition_id
tenant_id = self.getTenantId(tenant.data_partition_id)
ssm = boto3.client('ssm', region_name=self._region)
if(self._bucket_name == ""):
# get bucket name from ssm
response = ssm.get_parameter(
self._bucket_name = response['Parameter']['Value']
# for aws provider
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment