Commit 10bfa9b0 authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Updating so data partition is chosen at request time

parent bc9720d9
......@@ -23,12 +23,13 @@ class BaseClient:
Base client that is meant to be extended by service specific clients
"""
def __init__(self):
def __init__(self, data_partition_id):
"""
Base client gets initialized with configuration values and a bearer token
based on provider-specific logic
"""
self._parse_config()
self.data_partition_id = data_partition_id
self.unauth_retries = 0
if self.use_service_principal == 'True' or self.use_service_principal == 'true':
self._refresh_service_principal_token()
......@@ -54,7 +55,6 @@ class BaseClient:
if config_file_name not in found_names:
raise Exception('Could not find osdu_api.ini config file')
self.data_partition_id = config_parser.get('environment', 'data_partition_id')
self.storage_url = config_parser.get('environment', 'storage_url')
self.search_url = config_parser.get('environment', 'search_url')
self.data_workflow_url = config_parser.get('environment', 'data_workflow_url')
......
......@@ -25,8 +25,8 @@ from osdu_api.model.storage.legal import Legal
from osdu_api.model.storage.record_ancestry import RecordAncestry
from osdu_api.model.search.query_request import QueryRequest
record_client = RecordClient()
search_client = SearchClient()
record_client = RecordClient("opendes")
search_client = SearchClient("opendes")
kind = 'opendes:osdu:dataset-registry:0.0.1'
viewers = ['data.default.viewers@opendes.testing.com']
......
......@@ -27,10 +27,10 @@ from osdu_api.model.dataset_registry.create_dataset_registries import CreateData
from osdu_api.model.data_workflow.workflow_schedule import WorkflowSchedule
from osdu_api.model.data_workflow.get_workflow_schedules_request import GetWorkflowSchedulesRequest
data_workflow_client = DataWorkflowClient()
data_workflow_scheduling_client = DataWorkflowSchedulingClient()
dataset_registry_client = DatasetRegistryClient()
file_dms_client = FileDMSClient()
data_workflow_client = DataWorkflowClient("opendes")
data_workflow_scheduling_client = DataWorkflowSchedulingClient("opendes")
dataset_registry_client = DatasetRegistryClient("opendes")
file_dms_client = FileDMSClient("opendes")
# cd ../.. && pip3 uninstall osdu_api && python3 setup.py sdist bdist_wheel && python3 -m pip install ./dist/osdu_api-0.0.2-py3-none-any.whl && cd osdu_api/examples
......
from osdu_api.clients.dataset.dataset_dms_client import DatasetDmsClient
dataset_dms_client = DatasetDmsClient("opendes")
retrieval_instructions_response = dataset_dms_client.get_retrieval_instructions(record_id="opendes:dataset--File.Generic:6358621f99b64dc9bab5aeb82b0ed3ab")
print(retrieval_instructions_response.content)
print(retrieval_instructions_response.status_code)
\ No newline at end of file
......@@ -15,7 +15,7 @@ from osdu_api.clients.legal.legal_client import LegalClient
from osdu_api.model.legal.legal_tag import LegalTag
from osdu_api.model.legal.legal_tag_properties import LegalTagProperties
legal_client = LegalClient()
legal_client = LegalClient("opendes")
legal_tag_properties = LegalTagProperties(['US'], 'A1234', 2222222222222, 'default', 'Public Domain Data', 'Public', 'No Personal Data', 'EAR99')
......
......@@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
[environment]
data_partition_id=opendes
storage_url=%(BASE_URL)s/api/storage/v2
search_url=%(BASE_URL)s/api/search/v2
legal_url=%(BASE_URL)s/api/legal/v1
data_workflow_url=%(BASE_URL)s/api/data-workflow/v1
file_dms_url=%(BASE_URL)s/api/filedms/v2
dataset_url=%(BASE_URL)s/api/dataset-registry/v1
dataset_url=%(BASE_URL)s/api/dataset/v1
entitlements_url=%(BASE_URL)s/api/entitlements/v1
schema_url=%(BASE_URL)s/api/schema-service/v1
use_service_principal=True
......
......@@ -25,7 +25,7 @@ class TestBaseClient(unittest.TestCase):
# Arrange
# Act
client = BaseClient()
client = BaseClient("opendes")
# Assert
mocked_token_method.assert_called()
......@@ -34,7 +34,7 @@ class TestBaseClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, mocked_token_method):
# Arrange
client = BaseClient()
client = BaseClient("opendes")
client.service_principal_token = 'stubbed'
responses.add(responses.PUT, 'http://stubbed', json={'response': 'true'}, status=200)
......
......@@ -25,7 +25,7 @@ class TestDataWorkflowClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = DataWorkflowClient()
client = DataWorkflowClient("opendes")
client.service_principal_token = 'stubbed'
client.data_workflow_url = 'stubbed url'
client.headers = {}
......
......@@ -28,7 +28,7 @@ class TestDatasetRegistryClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = DatasetRegistryClient()
client = DatasetRegistryClient("opendes")
client.service_principal_token = 'stubbed'
client.dataset_registry_url = 'stubbed url'
client.headers = {}
......
......@@ -24,7 +24,7 @@ class Test_Entitlments_Client(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_file_upload(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = EntitlementsClient()
client = EntitlementsClient("opendes")
client.service_principal_token = 'stubbed'
client.entitlements_url = 'stubbed url'
client.headers = {}
......
......@@ -23,7 +23,7 @@ class TestLegalClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_file_upload(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = LegalClient()
client = LegalClient("opendes")
client.service_principal_token = 'stubbed'
client.legal_url = 'stubbed url'
client.headers = {}
......
......@@ -95,7 +95,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_create_update_records_model_record(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient()
record_client = RecordClient("opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -110,7 +110,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_latest_record_version(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient()
record_client = RecordClient("opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -127,7 +127,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_specific_record_version(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient()
record_client = RecordClient("opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......@@ -145,7 +145,7 @@ class TestRecordClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_get_record_versions(self, get_bearer_token_mock, make_request_mock):
# Arrange
record_client = RecordClient()
record_client = RecordClient("opendes")
record_client.service_principal_token = 'stubbed'
record_client.storage_url = 'stubbed url'
record_client.headers = {}
......
......@@ -25,7 +25,7 @@ class TestSeachClient(unittest.TestCase):
@mock.patch.object(BaseClient, '_refresh_service_principal_token', return_value="stubbed")
def test_make_request(self, get_bearer_token_mock, make_request_mock):
# Arrange
client = SearchClient()
client = SearchClient("opendes")
client.service_principal_token = 'stubbed'
client.data_workflow_url = 'stubbed url'
client.headers = {}
......
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