Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -------------------------------------------------------------------------------------------------
class GlobalLibrariesRequest(RWSAuthorizedGetRequest):
"""Return the list of global libraries as a RWSStudies object.
metadata_libraries are the list of libraries that you have access to as an
Architect Global Library Volume user
"""
def url_path(self):
return make_url('metadata', 'libraries')
def result(self, request):
return RWSStudies(request.text)
class GlobalLibraryDraftsRequest(RWSAuthorizedGetRequest):
"""Return the list of global library drafts"""
def __init__(self, project_name):
self.project_name = project_name
def url_path(self):
return make_url('metadata', 'libraries', self.project_name, 'drafts')
def result(self, request):
return RWSStudyMetadataVersions(request.text)
class GlobalLibraryVersionsRequest(RWSAuthorizedGetRequest):
"""Return the list of global library versions"""
def __init__(self, project_name):
'headers': self.headers}
return kw
def url_path(self):
return make_url("webservice.aspx?PostODMClinicalData")
def result(self, request):
return RWSPostResponse(request.text)
# -------------------------------------------------------------------------------------------------
# ODM Clinical Data Datasets
# -------------------------------------------------------------------------------------------------
class ODMDatasetBase(RWSAuthorizedGetRequest):
KNOWN_QUERY_OPTIONS = ['versionitem', 'rawsuffix', 'codelistsuffix',
'decodesuffix', 'stdsuffix', 'start']
def checkParams(self):
check_dataset_type(self.dataset_type)
# https://bitbucket.org/micktwomey/pyiso8601
def _querystring(self):
"""Additional keyword arguments"""
kw = {}
for key in self.KNOWN_QUERY_OPTIONS:
val = getattr(self, key)
if val is not None:
if key == 'start':
"""Return the list of clinical studies as a RWSStudies object.
Clinical studies are the studies that you have access to as an EDC user.
"""
def url_path(self):
return make_url('studies')
def result(self, request):
return RWSStudies(request.text)
# ----------------------------------------------------------------------------------------------------------------------
# Base request classes for study versions (could also be used for drafts if ever implemented by RWS)
# ----------------------------------------------------------------------------------------------------------------------
class VersionRequestBase(RWSAuthorizedGetRequest):
"""Base class for study and library metadata version requests"""
def __init__(self, project_name, oid):
self.project_name = project_name
self._oid = None # Oid is a version OID, an integer identifier
self.oid = oid
@property
def oid(self):
return self._oid
@oid.setter
def oid(self, value):
try:
int(value)
except ValueError:
def url_path(self):
return make_url('twohundred')
class CacheFlushRequest(RWSAuthorizedGetRequest):
"""Calls RWS cache-flush"""
def url_path(self):
return make_url('webservice.aspx?CacheFlush')
def result(self, request):
"""Return RWSResponse object for success"""
return RWSResponse(request.text)
class ClinicalStudiesRequest(RWSAuthorizedGetRequest):
"""Return the list of clinical studies as a RWSStudies object.
Clinical studies are the studies that you have access to as an EDC user.
"""
def url_path(self):
return make_url('studies')
def result(self, request):
return RWSStudies(request.text)
# ----------------------------------------------------------------------------------------------------------------------
# Base request classes for study versions (could also be used for drafts if ever implemented by RWS)
# ----------------------------------------------------------------------------------------------------------------------
class VersionRequestBase(RWSAuthorizedGetRequest):
def oid(self, value):
try:
int(value)
except ValueError:
raise ValueError('oid must be an integer')
self._oid = value
def result(self, request):
return request.text
# -----------------------------------------------------------------------------------------------------------------------
# Related to Architect Studies and their drafts/versions
# -----------------------------------------------------------------------------------------------------------------------
class MetadataStudiesRequest(RWSAuthorizedGetRequest):
"""Return the list of metadata studies as a RWSStudies object.
metadata_studies are the list of studies that you have access to as an
Architect user.
"""
def url_path(self):
return make_url('metadata', 'studies')
def result(self, request):
return RWSStudies(request.text)
class StudyDraftsRequest(RWSAuthorizedGetRequest):
"""Return the list of study drafts"""
def __init__(self, project_name):
class StudyVersionRequest(VersionRequestBase):
"""Return a study version as a string"""
def url_path(self):
return make_url('metadata', 'studies', self.project_name, 'versions', str(self._oid))
# NOTE: There is no StudyDraftRequest, this is something of an omission since you can list them...
# -------------------------------------------------------------------------------------------------
# Related to Architect Global Libraries and their drafts/versions
# -------------------------------------------------------------------------------------------------
class GlobalLibrariesRequest(RWSAuthorizedGetRequest):
"""Return the list of global libraries as a RWSStudies object.
metadata_libraries are the list of libraries that you have access to as an
Architect Global Library Volume user
"""
def url_path(self):
return make_url('metadata', 'libraries')
def result(self, request):
return RWSStudies(request.text)
class GlobalLibraryDraftsRequest(RWSAuthorizedGetRequest):
"""Return the list of global library drafts"""
def __init__(self, project_name):
class DiagnosticsRequest(RWSGetRequest):
"""Return the RWS build version number"""
def url_path(self):
return make_url('diagnostics')
class TwoHundredRequest(RWSGetRequest):
"""Return RWS MAuth information"""
def url_path(self):
return make_url('twohundred')
class CacheFlushRequest(RWSAuthorizedGetRequest):
"""Calls RWS cache-flush"""
def url_path(self):
return make_url('webservice.aspx?CacheFlush')
def result(self, request):
"""Return RWSResponse object for success"""
return RWSResponse(request.text)
class ClinicalStudiesRequest(RWSAuthorizedGetRequest):
"""Return the list of clinical studies as a RWSStudies object.
Clinical studies are the studies that you have access to as an EDC user.
"""
def url_path(self):
self.decodesuffix = decodesuffix
self.stdsuffix = stdsuffix
self.checkParams()
def url_path(self):
args = ['studies', self._studyname_environment(),
'subjects', str(self.subjectkey),
'datasets', self.dataset_type]
if self.formoid is not None:
args.append(self.formoid)
return make_url(*args, **self._querystring())
class ConfigurableDatasetRequest(RWSAuthorizedGetRequest):
VALID_DATASET_FORMATS = ()
def __init__(self,
dataset_name,
dataset_format='',
params={}):
"""
Create a new Configurable Dataset Request
:param dataset_name: Name for the dataset
:type dataset_name: str
:param dataset_format: Format for the dataset
:type dataset_format: str
:param params: set of parameters to pass to URL
:type params: dict
"""
self.dataset_name = dataset_name
method = "GET"
class RWSAuthorizedGetRequest(RWSGetRequest):
requires_authorization = True
class RWSPostRequest(RWSRequest):
method = "POST"
class RWSAuthorizedPostRequest(RWSPostRequest):
requires_authorization = True
class QueryOptionGetRequest(RWSAuthorizedGetRequest):
"""Manages requests that have known query string options"""
KNOWN_QUERY_OPTIONS = []
def _querystring(self):
"""Get additional keyword arguments"""
kw = {}
for key in self.KNOWN_QUERY_OPTIONS:
val = getattr(self, key)
if val is not None:
kw[key] = val
return kw
# ---------------------------------------------------------------------------------------------------------------------
# Implementations. These are all standards that have existed for a long time.
class StudyDraftsRequest(RWSAuthorizedGetRequest):
"""Return the list of study drafts"""
def __init__(self, project_name):
self.project_name = project_name
def url_path(self):
return make_url('metadata', 'studies', self.project_name, 'drafts')
def result(self, request):
return RWSStudyMetadataVersions(request.text)
class StudyVersionsRequest(RWSAuthorizedGetRequest):
"""Return the list of study versions"""
def __init__(self, project_name):
self.project_name = project_name
def url_path(self):
return make_url('metadata', 'studies', self.project_name, 'versions')
def result(self, request):
return RWSStudyMetadataVersions(request.text)
class StudyVersionRequest(VersionRequestBase):
"""Return a study version as a string"""
def url_path(self):