{"id":16318131,"url":"https://github.com/scorphus/okapi","last_synced_at":"2025-07-05T04:33:10.856Z","repository":{"id":148200911,"uuid":"41825607","full_name":"scorphus/okapi","owner":"scorphus","description":"Request Wrapper to instrument HTTP calls","archived":false,"fork":false,"pushed_at":"2015-09-02T21:16:05.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T20:28:05.697Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scorphus.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T20:20:15.000Z","updated_at":"2017-10-03T17:41:43.000Z","dependencies_parsed_at":"2023-04-06T23:06:55.206Z","dependency_job_id":null,"html_url":"https://github.com/scorphus/okapi","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scorphus%2Fokapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scorphus%2Fokapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scorphus%2Fokapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scorphus%2Fokapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scorphus","download_url":"https://codeload.github.com/scorphus/okapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990503,"owners_count":21995776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T22:10:02.939Z","updated_at":"2025-05-13T17:16:09.063Z","avatar_url":"https://github.com/scorphus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Okapi\n=====\n\nPython Library to send API info to Storage Server\n\n\nOkapi setup \n===========\nIn an existing project you should at least modify the following files:\n\n\nrequirements/base.txt\n---------------------\nAdd the following requirement to the project's settings. It won't be needed to\nadd ``requests`` if the project is already using it.\n``requests`` version should be \u003e= 2.2.11:\n\n.. code-block:: python\n\n    okapi==X.Y.Z\n\n\nsettings.py\n-----------\nAdd the following configuration to the project's settings:\n\n.. code-block:: python    \n\n    ########## OKAPI CONFIGURATION\n    OKAPI_PROJECT = 'your-project-name'\n\n    OKAPI_URI = None\n    if settings.has_section('okapi'):\n        OKAPI_URI = 'mongodb://{0},{1},{2}/{3}?replicaSet={4}'.format(\n\n            settings.get('okapi', 'host0'),\n            settings.get('okapi', 'host1'),\n            settings.get('okapi', 'host2'),\n            settings.get('okapi', 'name'),\n            settings.get('okapi', 'replica'),\n        )\n\n    ########## END OKAPI CONFIGURATION\n\nNote that if the project is already using *MongoDB*, you shouldn't store Okapi's\ndata into the same database. Okapi creates collections dynamically and could\nconflict with your the  project's.\n\n\nInitialization\n--------------\nInitialize Okapi in the ``models.py`` file of a basic application of the project.\nThis way Okapi will be imported at startup time:\n\n.. code-block:: python\n\n    import requests    \n    from django.conf import settings    \n\n    from okapi.api import Api\n\n    project_name = getattr(settings, 'OKAPI_PROJECT')\n    mongodb_uri = getattr(settings, 'MONGODB_URI')\n    okapi_client = Api(project_name, requests, mongodb_uri)\n\n\nUsage\n-----\nOnce initialized you can use Okapi wherever you use ``requests`` library.\nThink of Okapi as if you were using ``requests`` because they both have the same\nAPI.\n\nRequests documentation: http://docs.python-requests.org/en/latest/\n\n\nActivating/deactivating okapi in your project\n---------------------------------------------\nIn the file ``settings/base.py`` under the ``OKAPI CONFIGURATION`` section, you \ncan add a boolean setting in order to enable/disable okapi for your project. It \ncould be interesting to have it enabled in QA or staging environment and after\nit has been properly tested, activate it also in production.\n\nYou can have a section into ``your-project-name/settings/dev.py``: \n\n.. code-block:: python\n\n    ########## OKAPI CONFIGURATION\n    OKAPI_ENABLED = True\n    ########## END OKAPI CONFIGURATION\n\nAnother one into ``your-project-name/settings/production.py``: \n\n.. code-block:: python    \n\n    ########## OKAPI CONFIGURATION\n    OKAPI_ENABLED = False\n    ########## END OKAPI CONFIGURATION\n\nAnd so on. Note that ``get_custom_setting`` is a wrapper around ``getattr``. \nThen you could initialize it conditionally as shown below:\n\n.. code-block:: python\n\n    http_lib = requests\n    if (get_custom_setting('OKAPI_ENABLED') and okapi_uri is not None):\n        project_name = get_custom_setting('OKAPI_PROJECT', required=True)\n        okapi_uri = get_custom_setting('OKAPI_URI', required=True)\n        okapi_client = Api(project_name, requests, okapi_uri)\n        http_lib = okapi_client\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscorphus%2Fokapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscorphus%2Fokapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscorphus%2Fokapi/lists"}