{ "info": { "author": "ken dreyer", "author_email": "ktdreyer [at] ktdreyer [dot] com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "`python-nfsn`\n=============\n\n.. image:: https://travis-ci.org/ktdreyer/python-nfsn.svg?branch=master\n :target: https://travis-ci.org/ktdreyer/python-nfsn\n\n.. image:: https://coveralls.io/repos/ktdreyer/python-nfsn/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/ktdreyer/python-nfsn?branch=master\n\n.. image:: https://badge.fury.io/py/python-nfsn.svg\n :target: https://badge.fury.io/py/python-nfsn\n\nA modern Python library for accessing NearlyFreeSpeech.net's API.\n\n* Clean, Pythonic API\n* Supports 100% of NFSN's API (as of \"today\" :)\n* Supports Python 2.6 through 3.5\n* Good test coverage (using ``httpretty``)\n* Cryptographically secure salt generation with ``random.SystemRandom()``\n\nInstalling\n----------\n\nTo get running quickly, install from PyPI::\n\n pip install python-nfsn\n\nThis will place a ``pynfsn`` uility in your ``$PATH``.\n\nIf you want to hack on the code::\n\n git clone https://github.com/ktdreyer/python-nfsn\n cd python-nfsn\n virtualenv venv\n . venv/bin/activate\n python setup.py develop\n\n\nQuickstart\n==========\n\nObtain your API key from NFSN by submitting a secure support request via the\ncontrol panel, and store it in a JSON file in your home directory, like so::\n\n $ cat ~/.nfsn-api\n { \"login\": \"ktdreyer\", \"api-key\": \"aGVsbG90aGVyZWZyaWVuZA\" }\n\nUse the ``pynfsn`` command-line utility, a thin wrapper that lets you explore\nthe API ::\n\n $ pynfsn member ktdreyer accounts\n [u'D41D-8CD98F00', u'B204-E9800998', u'ECF8-427E6D7F']\n\n $ pynfsn member ktdreyer sites\n [u'coolsite', u'anothercoolsite']\n\n $ pynfsn dns example.com listRRs www\n [{u'data': u'example.nfshost.com.', u'scope': u'system', u'type': u'CNAME', u'name': u'www', u'ttl': u'600'}]\n\n $ pynfsn dns example.com addRR testing A 192.0.2.2\n\n $ pynfsn dns example.com removeRR testing A 192.0.2.2\n\n\nOr use the API directly in your own code:\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='myusername', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n rrs = nfsn.dns('example.com').listRRs(name='www')\n for rr in rrs:\n print(rr['name']) # eg. 'www'\n print(rr['type']) # eg. 'A'\n print(rr['data']) # eg. '192.0.2.2'\n\n\nAuthentication\n==============\n\nThere are three ways to pass your authentication credentials to the ``Nfsn()``\nconstructor:\n\n1) Call the constructor with no arguments:\n\n .. code-block:: python\n\n n = Nfsn()\n\n By default, the library will look for a ``$HOME/.nfsn-api`` JSON file that\n contains your username and API key, like so::\n\n $ cat ~/.nfsn-api\n { \"login\": \"ktdreyer\", \"api-key\": \"aGVsbG90aGVyZWZyaWVuZA\" }\n\n (This matches the same file and format that the Perl NFSN API uses for\n authentication, by the way.)\n\n2) Call the constructor with an explicit path to an API key login file:\n\n .. code-block:: python\n\n n = Nfsn(login_file='/etc/nfsn-api')\n\n In this example, the ``login_file`` should be a JSON file, similar to the\n example above.\n\n3) Specify a login string and API key string directly. You can skip the JSON\n login_file altogether and just pass the strings you need:\n\n .. code-block:: python\n\n n = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\nIf you do not enter the correct login and key combination, each time you access\na property or method using this library (see below), NearlyFreeSpeech.net will\nreturn a HTTP 401 error, and this library will raise a ``RuntimeError``.\n\n\nAPI Examples\n============\n\nSee https://members.nearlyfreespeech.net/wiki/API for more information.\n\n\nAccount API\n-----------\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n # A floating-point value, the balance on the account.\n # Example: 9.04\n nfsn.account('A1B2-C3D4E5F6').balance\n\n # The friendly, human-readable name for an account.\n # Example: \"Personal\" or \"Business\"\n nfsn.account('A1B2-C3D4E5F6').friendlyName\n nfsn.account('A1B2-C3D4E5F6').friendlyName = 'Business'\n\n # The status details for an account.\n # Example: { 'color': '#00b000', 'short': 'OK', 'status': 'Ok' }\n # (Note: returns an AttrDict)\n nfsn.account('A1B2-C3D4E5F6').status\n\n # The sites associated with an account.\n # Example: [ 'coolsite', 'anothercoolsite' ]\n nfsn.account('A1B2-C3D4E5F6').sites\n\n # Add a new site to an account.\n nfsn.account('A1B2-C3D4E5F6').addSite(site='testing')\n\n # Add a new warning to an account.\n nfsn.account('A1B2-C3D4E5F6').addWarning(balance=1.23)\n\n # Remove a warning from an account.\n nfsn.account('A1B2-C3D4E5F6').removeWarning(balance=1.23)\n\nDNS API\n-------\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n # Get or set the expiration value for a DNS zone.\n nfsn.dns('example.com').expire # Example: 86400\n nfsn.dns('example.com').expire = 86401\n\n # Get the minTTL value for a DNS zone.\n # Example: 180\n nfsn.dns('example.com').minTTL\n\n # Get the minTTL value for a DNS zone.\n # Example: 600\n nfsn.dns('example.com').refresh\n\n # Get the retry value for a DNS zone.\n # Example: 180\n nfsn.dns('example.com').retry\n\n # Get the serial value for a DNS zone.\n # Example: 1414129428\n nfsn.dns('example.com').serial\n\n # Add a DNS resource record. The name+type must not exist yet.\n nfsn.dns('example.com').addRR(\n name = 'testing',\n type = 'A',\n data = '192.0.2.2'\n )\n\n # List all DNS resource records:\n # (Note: returns an AttrDict)\n # Example:\n # [{'data': '192.0.2.1',\n # 'name': '',\n # 'scope': 'member',\n # 'ttl': '3600',\n # 'type': 'A'},\n # {'data': 'ns.phx2.nearlyfreespeech.net.',\n # 'name': '',\n # 'scope': 'member',\n # 'ttl': '3600',\n # 'type': 'NS'}]\n nfsn.dns('example.com').listRRs()\n\n # List all DNS resource records for 'www.example.com':\n # (Note: returns an AttrDict)\n # Example:\n # [{'data': '192.0.2.1',\n # 'name': 'www',\n # 'scope': 'member',\n # 'ttl': '3600',\n # 'type': 'A'}]\n nfsn.dns('example.com').listRRs(name='www')\n\n # Add a DNS resource record.\n # The name+type must exist, or Nfsn will raise an an error. You must\n # specify all three parameters (name, type, data).\n nfsn.dns('example.com').removeRR(\n name = 'testing',\n type = 'A',\n data = '192.0.2.2'\n )\n\n\nEmail API\n---------\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n # List all email forwarding.\n # Example: { 'hello': 'customerservice@example.net'}\n # (Note: returns an AttrDict)\n nfsn.email('example.com').listForwards()\n\n # Forward all 'hi@example.com' mail to 'h@example.net':\n nfsn.email('example.com').setForward(forward='hi', dest_email='h@example.net')\n # ... And remove the email forward:\n nfsn.email('example.com').removeForward(forward='hi')\n\n\nMember API\n----------\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n # Get a list of all accounts belonging to a member.\n # Example: [ 'A1B2-C3D4E5F6' ]\n nfsn.member('ktdreyer').accounts\n\n # Get a list of all sites belonging to a member.\n # Example: [ 'coolsite', 'anothercoolsite' ]\n nfsn.member('ktdreyer').sites\n\nSite API\n--------\n\n.. code-block:: python\n\n from nfsn import Nfsn\n\n nfsn = Nfsn(login='ktdreyer', api_key='aGVsbG90aGVyZWZyaWVuZA')\n\n # Add or remove an alias for a site:\n nfsn.site('mycoolsite').addAlias(alias='mobile.example.com')\n nfsn.site('mycoolsite').removeAlias(alias='mobile.example.com')\n\n\nTypes and Errors\n================\n\nNote that since we use `Beanbag `_\ninternally, when we return a dict value, it is really an `AttrDict\n`_. If you want to convert the value to\na plain dict, you will need to use the ``+`` operator. Prepend the value with a\n``+`` sign, like so:\n\n.. code-block:: python\n\n rrs = nfsn.dns('example.com').listRRs()\n print +rrs\n\nIf you try to access a non-existent property or method, NearlyFreeSpeech.net\nwill return a HTTP 404 Not Found error, and this library will raise a\n``BeanBagException``.\n\n\nLicense and Copyright\n=====================\n\nThis software is CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. See\n``COPYING`` for the full CC0 text.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ktdreyer/python-nfsn", "keywords": "nearlyfreespeech.net", "license": "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "maintainer": null, "maintainer_email": null, "name": "python-nfsn", "package_url": "https://pypi.org/project/python-nfsn/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-nfsn/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/ktdreyer/python-nfsn" }, "release_url": "https://pypi.org/project/python-nfsn/1.1.1/", "requires_dist": null, "requires_python": null, "summary": "Interact with NearlyFreeSpeech's API", "version": "1.1.1" }, "last_serial": 1858598, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "3a69bba9e2abcf6246aadf706d73a648", "sha256": "6d69f9b4925989d50a9e7d1533c6ee4b2cad0a257f77020c85488ffa66ba8e78" }, "downloads": -1, "filename": "python-nfsn-1.1.0.tar.gz", "has_sig": true, "md5_digest": "3a69bba9e2abcf6246aadf706d73a648", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13184, "upload_time": "2015-11-29T04:01:39", "url": "https://files.pythonhosted.org/packages/e1/8b/53a60046d139ae637b37434a4576a695c7288d95683a84374b007210246a/python-nfsn-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "3774bb4831e2c9a64d4b779dfb0c9884", "sha256": "32e3ee252c8b4adf9f9cd33fcedd6c9a2cf43532b924dc5c7602d5cd12664189" }, "downloads": -1, "filename": "python-nfsn-1.1.1.tar.gz", "has_sig": true, "md5_digest": "3774bb4831e2c9a64d4b779dfb0c9884", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14733, "upload_time": "2015-12-12T08:30:19", "url": "https://files.pythonhosted.org/packages/ba/b0/3ebdb84f06f5e9719af38cabe962ad7ddbedfd9d7946407d8e4f481c4723/python-nfsn-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3774bb4831e2c9a64d4b779dfb0c9884", "sha256": "32e3ee252c8b4adf9f9cd33fcedd6c9a2cf43532b924dc5c7602d5cd12664189" }, "downloads": -1, "filename": "python-nfsn-1.1.1.tar.gz", "has_sig": true, "md5_digest": "3774bb4831e2c9a64d4b779dfb0c9884", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14733, "upload_time": "2015-12-12T08:30:19", "url": "https://files.pythonhosted.org/packages/ba/b0/3ebdb84f06f5e9719af38cabe962ad7ddbedfd9d7946407d8e4f481c4723/python-nfsn-1.1.1.tar.gz" } ] }