Example #1
0
    def put(self, vo):
        """ Update the details for a given VO

        .. :quickref: VO; Update a VOs.

        :param vo: VO to be updated.
        :<json string description: Desciption of VO.
        :<json string email: Admin email for VO.
        :status 200: VO updated successfully.
        :status 401: Invalid Auth Token.
        :status 404: VO not found.
        :status 409: Unsupported operation.
        """
        parameters = json_parameters()
        try:
            update_vo(updated_vo=vo,
                      parameters=parameters,
                      issuer=request.environ.get('issuer'),
                      vo=request.environ.get('vo'))
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
        except VONotFound as error:
            return generate_http_error_flask(404, error)
        except UnsupportedOperation as error:
            return generate_http_error_flask(409, error)

        return '', 200
Example #2
0
 def test_update_vo(self):
     """ MULTI VO (CORE): Test updating VOs """
     description = generate_uuid()
     email = generate_uuid()
     parameters = {'vo': self.new_vo['vo'], 'description': description, 'email': email}
     with assert_raises(AccessDenied):
         vo_api.update_vo(self.new_vo['vo'], parameters, 'root', **self.vo)
     vo_api.update_vo(self.new_vo['vo'], parameters, 'super_root', 'def')
     vo_update_success = False
     for v in vo_api.list_vos('super_root', 'def'):
         if v['vo'] == parameters['vo']:
             assert_equal(email, v['email'])
             assert_equal(description, v['description'])
             vo_update_success = True
     assert_true(vo_update_success)
Example #3
0
File: vo.py Project: stfc/rucio
    def put(self, vo):
        """ Update the details for a given VO

        .. :quickref: VO; Update a VOs.

        :param vo: VO to be updated.
        :<json string description: Desciption of VO.
        :<json string email: Admin email for VO.
        :status 200: VO updated successfully.
        :status 401: Invalid Auth Token.
        :status 404: VO not found.
        :status 409: Unsupported operation.
        :status 500: Internal Error.

        """
        json_data = request.data.decode()

        try:
            parameters = loads(json_data)
        except ValueError:
            return generate_http_error_flask(
                400, 'ValueError', 'cannot decode json parameter dictionary')

        try:
            update_vo(updated_vo=vo,
                      parameters=parameters,
                      issuer=request.environ.get('issuer'),
                      vo=request.environ.get('vo'))
        except AccessDenied as error:
            return generate_http_error_flask(401, 'AccessDenied',
                                             error.args[0])
        except VONotFound as error:
            return generate_http_error_flask(404, 'VONotFound', error.args[0])
        except UnsupportedOperation as error:
            return generate_http_error_flask(409, 'UnsupportedOperation',
                                             error.args[0])
        except RucioException as error:
            return generate_http_error_flask(500, error.__class__.__name__,
                                             error.args[0])
        except Exception as error:
            print(format_exc())
            return str(error), 500

        return '', 200
Example #4
0
    def PUT(self, updated_vo):
        """ Update the details for a given VO

        HTTP Success:
            200 OK

        HTTP Error:
            400 Bad Request
            401 Unauthorized
            404 Not Found
            409 Conflict
            500 InternalError

        :param updated_vo: VO to be updated.
        """
        json_data = data().decode()

        try:
            parameters = loads(json_data)
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'cannot decode json parameter dictionary')

        try:
            update_vo(updated_vo=updated_vo, parameters=parameters, issuer=ctx.env.get('issuer'), vo=ctx.env.get('vo'))
        except AccessDenied as error:
            raise generate_http_error(401, 'AccessDenied', error.args[0])
        except VONotFound as error:
            raise generate_http_error(404, 'VONotFound', error.args[0])
        except UnsupportedOperation as error:
            raise generate_http_error(409, 'UnsupportedOperation', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(error)
            print(format_exc())
            raise InternalError(error)

        raise OK()