Beispiel #1
0
def setup():
    """
    setup state called once for the class
    """
    reset()

    mygene = SmartAPI(MYGENE_URL)
    mygene.username = '******'
    mygene.refresh()
    mygene.check()
    mygene.save()

    mychem = SmartAPI(MYCHEM_URL)
    mychem.username = '******'
    mychem.refresh()
    mychem.check()
    mychem.save()

    refresh()
Beispiel #2
0
    async def post(self):
        """
        Add an API document
        """

        if SmartAPI.find(self.args.url, "url"):
            raise HTTPError(409)

        try:
            file = await download_async(self.args.url)
        except DownloadError as err:
            raise BadRequest(details=str(err)) from err

        try:
            smartapi = SmartAPI(self.args.url)
            smartapi.raw = file.raw
            smartapi.validate()
        except (ControllerError, AssertionError) as err:
            raise BadRequest(details=str(err)) from err

        if self.args.dryrun:
            raise Finish({
                'success':
                True,
                'details':
                f"[Dryrun] Valid {smartapi.version} Metadata"
            })

        try:
            smartapi.username = self.current_user['login']
            smartapi.refresh(file)  # populate webdoc meta
            _id = smartapi.save()
        except ControllerError as err:
            raise BadRequest(details=str(err)) from err
        else:
            self.finish({'success': True, '_id': _id})
            await self._notify(smartapi)