@@ -69,6 +69,7 @@ class DraftsCreateApi(APIView):
6969 request_body = BCO_DRAFT_SCHEMA
7070
7171 @swagger_auto_schema (
72+ operation_id = "api_objects_drafts_create" ,
7273 request_body = request_body ,
7374 responses = {
7475 200 : "All requests were accepted." ,
@@ -183,6 +184,7 @@ class DraftRetrieveApi(APIView):
183184 """
184185
185186 @swagger_auto_schema (
187+ operation_id = "api_get_draft" ,
186188 manual_parameters = [
187189 openapi .Parameter (
188190 "bco_accession" ,
@@ -211,6 +213,83 @@ def get(self, request, bco_accession):
211213 status = status .HTTP_403_FORBIDDEN ,
212214 data = {"message" : f"User, { requester } , does not have draft permissions" \
213215 + f" for { bco_accession } ." })
214- else :
215- bco_counter_increment (bco_instance )
216- return Response (status = status .HTTP_200_OK , data = bco_instance .contents )
216+ if bco_instance is None :
217+ return Response (
218+ status = status .HTTP_404_NOT_FOUND ,
219+ data = {"message" : f"{ bco_accession } /DRAFT, could " \
220+ + "not be found on the server."
221+ }
222+ )
223+
224+ bco_counter_increment (bco_instance )
225+ return Response (status = status .HTTP_200_OK , data = bco_instance .contents )
226+
227+ class PublishedRetrieveApi (APIView ):
228+ """Get Published BCO
229+
230+ API view for retrieving a specific version of a published BioCompute
231+ Object (BCO).
232+
233+ Retrieve the contents of a published BCO by specifying its accession
234+ number and version. Authentication is not required to access most
235+ published BCOs, reflecting the public nature of these objects. If
236+ the prefix is not public than the user's ability to view this BCO
237+ is verified.
238+
239+ Parameters:
240+ - `bco_accession`:
241+ Specifies the accession number of the BCO to be retrieved.
242+
243+ - `bco_version`:
244+ Specifies the version of the BCO to be retrieved.
245+ """
246+
247+ @swagger_auto_schema (
248+ operation_id = "api_get_published" ,
249+ manual_parameters = [
250+ openapi .Parameter (
251+ "bco_accession" ,
252+ openapi .IN_PATH ,
253+ description = "BCO accession to be viewed." ,
254+ type = openapi .TYPE_STRING ,
255+ default = "BCO_000000"
256+ ),
257+ openapi .Parameter (
258+ "bco_version" ,
259+ openapi .IN_PATH ,
260+ description = "BCO version to be viewed." ,
261+ type = openapi .TYPE_STRING ,
262+ default = "1.0"
263+ )
264+ ],
265+ responses = {
266+ 200 : "Success. Object contents returned" ,
267+ 401 : "Authentication credentials were not provided, or"
268+ " the token was invalid." ,
269+ 403 : "Forbidden. The requestor does not have appropriate permissions." ,
270+ 404 : "Not found. That BCO could not be found on the server."
271+ },
272+ tags = ["BCO Management" ],
273+ )
274+
275+ def get (self , request , bco_accession , bco_version ):
276+ requester = request .user
277+ print (requester )
278+ bco_instance = retrieve_bco (bco_accession , requester , bco_version )
279+ if bco_instance is False :
280+ return Response (
281+ status = status .HTTP_403_FORBIDDEN ,
282+ data = {"message" : f"User, { requester } , does not have draft permissions" \
283+ + f" for { bco_accession } ." })
284+
285+ if bco_instance is None :
286+ return Response (
287+ status = status .HTTP_404_NOT_FOUND ,
288+ data = {"message" : f"{ bco_accession } /{ bco_version } , could " \
289+ + "not be found on the server."
290+ }
291+ )
292+
293+ bco_counter_increment (bco_instance )
294+ return Response (status = status .HTTP_200_OK , data = bco_instance .contents )
295+
0 commit comments