def get(self, instrument_id, cycle_id):
     """
     ---
     summary: Get the investigations for a given Facility Cycle & Instrument
     description: Given an Instrument id and Facility Cycle id, get the
         investigations that occur within that cycle on that instrument, subject
         to the given filters
     tags:
         - Investigations
     parameters:
         - in: path
           required: true
           name: instrument_id
           description: The id of the instrument to retrieve the investigations
               of
           schema:
             type: integer
         - in: path
           required: true
           name: cycle_id
           description: The id of the facility cycle to retrieve the
               investigations
           schema:
             type: integer
         - WHERE_FILTER
         - ORDER_FILTER
         - LIMIT_FILTER
         - SKIP_FILTER
         - DISTINCT_FILTER
         - INCLUDE_FILTER
     responses:
         200:
             description: Success - returns a list of the investigations for the
                 given instrument and facility cycle that satisfy the filters
             content:
                 application/json:
                     schema:
                         type: array
                         items:
                             $ref: '#/components/schemas/INVESTIGATION'
         400:
             description: Bad request - Something was wrong with the request
         401:
             description: Unauthorized - No session ID found in HTTP Auth. header
         403:
             description: Forbidden - The session ID provided is invalid
         404:
             description: No such record - Unable to find a record in ICAT
     """
     return (
         backend.
         get_investigations_for_instrument_facility_cycle_with_filters(
             get_session_id_from_auth_header(),
             instrument_id,
             cycle_id,
             get_filters_from_query_string(),
             **kwargs,
         ),
         200,
     )
Esempio n. 2
0
 def put(self):
     """
     Refreshes a users session
     :return: String: The session ID that has been refreshed, 200
     ---
     summary: Refresh session
     description: Refreshes a users session
     tags:
      - Sessions
     responses:
       200:
         description: Success - the user's session ID that has been refreshed
         content:
           application/json:
             schema:
               type: string
               description: Session ID
               example: xxxxxx-yyyyyyy-zzzzzz
       401:
         description: Unauthorized - No session ID found in HTTP Auth. header
       403:
         description: Forbidden - The session ID provided is invalid
     """
     return backend.refresh(get_session_id_from_auth_header(),
                            **kwargs), 200
Esempio n. 3
0
 def get(self, id_):
     return (
         backend.get_with_id(
             get_session_id_from_auth_header(), entity_type, id_, **kwargs,
         ),
         200,
     )
Esempio n. 4
0
 def get(self):
     filters = get_filters_from_query_string()
     return (
         backend.get_one_with_filters(
             get_session_id_from_auth_header(), entity_type, filters, **kwargs,
         ),
         200,
     )
Esempio n. 5
0
    def test_valid_header(self, flask_test_app_db,
                          valid_db_credentials_header):
        with flask_test_app_db:
            flask_test_app_db.get("/", headers=valid_db_credentials_header)
            session_id = valid_db_credentials_header["Authorization"].split(
            )[1]

            assert session_id == get_session_id_from_auth_header()
Esempio n. 6
0
 def post(self):
     return (
         backend.create(
             get_session_id_from_auth_header(),
             entity_type,
             request.json,
             **kwargs,
         ),
         200,
     )
 def get(self, id_):
     """
     ---
     summary: Count an Instrument's FacilityCycles
     description: Return the count of the Facility Cycles that have
         investigations that occur within that cycle on the specified instrument
         that would be retrieved given the filters provided
     tags:
         - FacilityCycles
     parameters:
         - in: path
           required: true
           name: id_
           description: The id of the instrument to count the facility cycles of
           schema:
             type: integer
         - WHERE_FILTER
         - DISTINCT_FILTER
     responses:
         200:
             description: Success - The count of the instrument's facility cycles
                 that satisfy the filters
             content:
                 application/json:
                     schema:
                         type: integer
         400:
             description: Bad request - Something was wrong with the request
         401:
             description: Unauthorized - No session ID found in HTTP Auth. header
         403:
             description: Forbidden - The session ID provided is invalid
         404:
             description: No such record - Unable to find a record in ICAT
     """
     return (
         backend.get_facility_cycles_for_instrument_count_with_filters(
             get_session_id_from_auth_header(),
             id_,
             get_filters_from_query_string(),
             **kwargs,
         ),
         200,
     )
Esempio n. 8
0
 def get(self):
     """
     Gives details of a users session
     :return: String: Details of the session, 200
     ---
     summary: Get session details
     description: Gives details of a user's session
     tags:
      - Sessions
     responses:
       200:
         description: Success - a user's session details
         content:
           application/json:
             schema:
               type: object
               properties:
                 ID:
                   type: string
                   description: The session ID
                   example: xxxxxx-yyyyyyy-zzzzzz
                 EXPIREDATETIME:
                   type: string
                   format: datetime
                   description: When this session expires
                   example: "2017-07-21T17:32:28Z"
                 USERNAME:
                   type: string
                   description: Username associated with this session
       401:
         description: Unauthorized - No session ID found in HTTP Auth. header
       403:
         description: Forbidden - The session ID provided is invalid
     """
     return (
         backend.get_session_details(
             get_session_id_from_auth_header(),
             **kwargs,
         ),
         200,
     )
Esempio n. 9
0
 def delete(self):
     """
     Deletes a users sessionID when they logout
     :return: Blank response, 200
     ---
     summary: Delete session
     description: Deletes a users sessionID when they logout
     tags:
      - Sessions
     responses:
       200:
         description: Success - User's session was successfully deleted
       400:
         description: Bad request - something was wrong with the request
       401:
         description: Unauthorized - No session ID found in HTTP Auth. header
       403:
         description: Forbidden - The session ID provided is invalid
       404:
         description: Not Found - Unable to find session ID
     """
     backend.logout(get_session_id_from_auth_header(), **kwargs)
     return "", 200
Esempio n. 10
0
 def patch(self, id_):
     session_id = get_session_id_from_auth_header()
     backend.update_with_id(
         session_id, entity_type, id_, request.json, **kwargs,
     )
     return backend.get_with_id(session_id, entity_type, id_, **kwargs), 200
Esempio n. 11
0
 def delete(self, id_):
     backend.delete_with_id(
         get_session_id_from_auth_header(), entity_type, id_, **kwargs,
     )
     return "", 204
Esempio n. 12
0
 def test_invalid_header(self, flask_test_app_db,
                         invalid_credentials_header):
     with flask_test_app_db:
         flask_test_app_db.get("/", headers=invalid_credentials_header)
         with pytest.raises(AuthenticationError):
             get_session_id_from_auth_header()
Esempio n. 13
0
 def test_invalid_no_credentials_in_header(self, flask_test_app_db):
     with flask_test_app_db:
         flask_test_app_db.get("/")
         with pytest.raises(MissingCredentialsError):
             get_session_id_from_auth_header()