Esempio n. 1
0
def api():
    load_dotenv(dotenv_path="./example.env")
    conf = fatcat_client.Configuration()
    conf.host = "http://localhost:9411/v0"
    conf.api_key["Authorization"] = os.getenv("FATCAT_API_AUTH_TOKEN")
    conf.api_key_prefix["Authorization"] = "Bearer"
    api_client = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
    api_client.editor_id = "aaaaaaaaaaaabkvkaaaaaaaaae"
    return api_client
Esempio n. 2
0
def public_api(host_uri):
    """
    Note: unlike the authenticated variant, this helper might get called even
    if the API isn't going to be used, so it's important that it doesn't try to
    actually connect to the API host or something.
    """
    conf = fatcat_client.Configuration()
    conf.host = host_uri
    return fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
Esempio n. 3
0
def run_export_releases(args):
    conf = fatcat_client.Configuration()
    conf.host = args.host_url
    api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))

    for line in args.ident_file:
        ident = uuid2fcid(line.split()[0])
        release = api.get_release(id=ident, expand="all")
        args.json_output.write(json.dumps(release.to_dict()) + "\n")
Esempio n. 4
0
def run_export_changelog(args):
    conf = fatcat_client.Configuration()
    conf.host = args.host_url
    api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))

    end = args.end
    if end is None:
        latest = api.get_changelog(limit=1)[0]
        end = latest.index

    for i in range(args.start, end):
        entry = api.get_changelog_entry(id=i)
        args.json_output.write(json.dumps(entry.to_dict()) + "\n")
Esempio n. 5
0
 def __init__(self, host_url, issn_map_file=None):
     conf = fatcat_client.Configuration()
     conf.host = host_url
     self.api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))
     self._issnl_id_map = dict()
     self._orcid_id_map = dict()
     self._doi_id_map = dict()
     self._issn_issnl_map = None
     self._orcid_regex = re.compile("^\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]$")
     if issn_map_file:
         self.read_issn_map_file(issn_map_file)
     self.processed_lines = 0
     self.insert_count = 0
     self.update_count = 0
Esempio n. 6
0
def authenticated_api(host_uri, token=None):
    """
    Note: if this helper is called, it's implied that an actual API connection
    is needed, so it does try to connect and verify credentials.
    """

    conf = fatcat_client.Configuration()
    conf.host = host_uri
    if not token:
        token = os.environ['FATCAT_API_AUTH_TOKEN']
    if not token:
        sys.stderr.write(
            'This client requires a fatcat API token (eg, in env var FATCAT_API_AUTH_TOKEN)\n'
        )
        sys.exit(-1)

    conf.api_key["Authorization"] = token
    conf.api_key_prefix["Authorization"] = "Bearer"
    api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))

    # verify up front that auth is working
    api.auth_check()

    return api
Esempio n. 7
0
from flask import Flask
from flask_uuid import FlaskUUID
from flask_debugtoolbar import DebugToolbarExtension
from config import Config
import fatcat_client

toolbar = DebugToolbarExtension()
app = Flask(__name__)
app.config.from_object(Config)
toolbar = DebugToolbarExtension(app)
FlaskUUID(app)

conf = fatcat_client.Configuration()
conf.host = "http://localhost:9411/v0"
api = fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))

from fatcat import routes
Esempio n. 8
0
    print(" / _| __ _| |_ ___ __ _| |_| |")
    print("| |_ / _` | __/ __/ _` | __| |")
    print("|  _| (_| | || (_| (_| | |_|_|")
    print("|_|  \__,_|\__\___\__,_|\__(_)")
    print()

    admin_id = "aaaaaaaaaaaabkvkaaaaaaaaae"

    #fatcat_client.configuration.api_key['Authorization'] = 'YOUR_API_KEY'
    #fatcat_client.configuration.api_key_prefix['Authorization'] = 'Bearer'
    local_conf = fatcat_client.Configuration()
    local_conf.api_key[
        "Authorization"] = "AgEPZGV2LmZhdGNhdC53aWtpAhYyMDE5MDEwMS1kZXYtZHVtbXkta2V5AAImZWRpdG9yX2lkID0gYWFhYWFhYWFhYWFhYmt2a2FhYWFhYWFhYWkAAht0aW1lID4gMjAxOS0wMS0wOVQwMDo1Nzo1MloAAAYgnroNha1hSftChtxHGTnLEmM/pY8MeQS/jBSV0UNvXug="
    local_conf.api_key_prefix["Authorization"] = "Bearer"
    local_conf.host = 'http://localhost:9411/v0'
    local_conf.debug = True
    local_api = fatcat_client.DefaultApi(fatcat_client.ApiClient(local_conf))

    #prod_conf = fatcat_client.Configuration()
    #prod_conf.api_key["Authorization"] = "AgEPZGV2LmZhdGNhdC53aWtpAg4yMDE4LTEyLTMxLWRldgACJmVkaXRvcl9pZCA9IGFhYWFhYWFhYWFhYWJrdmthYWFhYWFhYWFlAAIeY3JlYXRlZCA9IDIwMTgtMTItMzFUMjE6MTU6NDdaAAAGIMWFZeZ54pH4OzNl5+U5X3p1H1rMioSuIldihuiM5XAw"
    #prod_conf.api_key_prefix["Authorization"] = "Bearer"
    #prod_conf.host = 'https://api.fatcat.wiki/v0'
    #prod_api = fatcat_client.DefaultApi(fatcat_client.ApiClient(prod_conf))

    qa_conf = fatcat_client.Configuration()
    qa_conf.api_key[
        "Authorization"] = "AgEPZGV2LmZhdGNhdC53aWtpAg4yMDE4LTEyLTMxLWRldgACJmVkaXRvcl9pZCA9IGFhYWFhYWFhYWFhYWJrdmthYWFhYWFhYWFlAAIeY3JlYXRlZCA9IDIwMTgtMTItMzFUMjE6MTU6NDdaAAAGIMWFZeZ54pH4OzNl5+U5X3p1H1rMioSuIldihuiM5XAw"
    qa_conf.api_key_prefix["Authorization"] = "Bearer"
    qa_conf.host = 'https://api.qa.fatcat.wiki/v0'
    qa_api = fatcat_client.DefaultApi(fatcat_client.ApiClient(qa_conf))
Esempio n. 9
0
def auth_api(token):
    conf = fatcat_client.Configuration()
    conf.api_key["Authorization"] = token
    conf.api_key_prefix["Authorization"] = "Bearer"
    conf.host = Config.FATCAT_API_HOST
    return fatcat_client.DefaultApi(fatcat_client.ApiClient(conf))