linode_api4
===========
The official python library for the `Linode API v4`_ in python.
.. _Linode API v4: https://developers.linode.com/api/v4/
.. image:: https://travis-ci.com/linode/linode_api4-python.svg?branch=master
:target: https://travis-ci.com/linode/linode_api4-python
.. image:: https://badge.fury.io/py/linode-api4.svg
:target: https://badge.fury.io/py/linode-api4
.. image:: https://readthedocs.org/projects/linode-api4/badge/?version=latest
:target: https://linode-api4.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Installation
------------
::
pip install linode_api4
Building from Source
--------------------
To build and install this package:
- Clone this repository
- ``./setup.py install``
Usage
=====
Quick Start
-----------
In order to authenticate with the Linode API, you will first need to create a
`Linode Personal Access Token`_ with your desired account permissions.
The following code sample can help you quickly get started using this package.
.. code-block:: python
from linode_api4 import LinodeClient, Instance
# Create a Linode API client
client = LinodeClient("MY_PERSONAL_ACCESS_TOKEN")
# Create a new Linode
new_linode, root_pass = client.linode.instance_create(
ltype="g6-nanode-1",
region="us-southeast",
image="linode/ubuntu22.04",
label="my-ubuntu-linode"
)
# Print info about the Linode
print("Linode IP:", new_linode.ipv4[0])
print("Linode Root Password:", root_pass)
# List all Linodes on the account
my_linodes = client.linode.instances()
# Print the Label of every Linode on the account
print("All Instances:")
for instance in my_linodes:
print(instance.label)
# List Linodes in the us-southeast region
specific_linodes = client.linode.instances(
Instance.region == "us-southeast"
)
# Print the label of each Linode in us-southeast
print("Instances in us-southeast:")
for instance in specific_linodes:
print(instance.label)
# Delete the new instance
new_linode.delete()
Check out the `Getting Started guide`_ for more details on getting started
with this library, or read `the docs`_ for more extensive documentation.
.. _Linode Personal Access Token: https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/
.. _Getting Started guide: http://linode_api4.readthedocs.io/en/latest/guides/getting_started.html
.. _the docs: http://linode_api4.readthedocs.io/en/latest/index.html
Examples
--------
See the `Install on a Linode`_ example project for a simple use case demonstrating
many of the features of this library.
.. _Install on a Linode: https://github.com/linode/linode_api4-python/tree/master/examples/install-on-linode
Contributing
============
Tests
-----
Tests live in the ``tests`` directory. When invoking tests, make sure you are
in the root directory of this project. To run the full suite across all
supported python versions, use tox_:
.. code-block:: shell
tox
Running tox also runs pylint and coverage reports.
The test suite uses fixtures stored as JSON in ``test/fixtures``. These files
contain sanitized JSON responses from the API - the file name is the URL called
to produce the response, replacing any slashes with underscores.
Test classes should extend ``test.base.ClientBaseCase``. This provides them
with ``self.client``, a ``LinodeClient`` object that is set up to work with
tests. Importantly, any GET request made by this object will be mocked to
retrieve data from the test fixtures. This includes lazy-loaded objects using
this client (and by extension related models).
When testing against requests other than GET requests, ``self.mock_post`` (and
equivalent methods for other HTTP verbs) can be used in a ``with`` block to
mock out the intended request type. These functions accept the relative path
from the api base url that should be returned, for example::
# this should return the result of GET /linode/instances/123
with self.mock_post('/linode/instances/123'):
linode = self.client.linode.instance_create('g6-standard-2', 'us-east')
self.assertEqual(linode.id, 123) # passes
.. _tox: http://tox.readthedocs.io
Documentation
-------------
This library is documented with Sphinx_. Docs live in the ``docs`` directory.
The easiest way to build the docs is to run ``sphinx-autobuild`` in that
folder.
Classes and functions inside the library should be annotated with sphinx-compliant
docstrings which will be used to automatically generate documentation for the
library. When contributing, be sure to update documentation or include new
docstrings where applicable to keep the library's documentation up to date
and useful.
**Missing or inaccurate documentation is a bug**. If you notice that the
documentation for this library is out of date or unclear, please
`open an issue`_ to make us aware of the problem.
.. _Sphinx: http://www.sphinx-doc.org/en/master/index.html
.. _open an issue: https://github.com/linode/linode_api4-python/issues/new
Contributing
------------
Please follow the `Contributing Guidelines`_ when making a contribution.
.. _Contributing Guidelines: https://github.com/linode/linode_api4-python/blob/master/CONTRIBUTING.md
Raw data
{
"_id": null,
"home_page": "https://github.com/linode/linode_api4-python",
"name": "linode-api4-testrelease",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "linode cloud hosting infrastructure",
"author": "Linode",
"author_email": "developers@linode.com",
"download_url": "https://files.pythonhosted.org/packages/a9/7e/032779255c51db6b91e944edd4801b859a910e0e32c0c2feda7e665bf423/linode_api4-testrelease-5.55.4.tar.gz",
"platform": null,
"description": "linode_api4\n===========\n\nThe official python library for the `Linode API v4`_ in python.\n\n.. _Linode API v4: https://developers.linode.com/api/v4/\n\n.. image:: https://travis-ci.com/linode/linode_api4-python.svg?branch=master\n :target: https://travis-ci.com/linode/linode_api4-python\n\n.. image:: https://badge.fury.io/py/linode-api4.svg\n :target: https://badge.fury.io/py/linode-api4\n\n.. image:: https://readthedocs.org/projects/linode-api4/badge/?version=latest\n :target: https://linode-api4.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\nInstallation\n------------\n::\n\n pip install linode_api4\n\nBuilding from Source\n--------------------\n\nTo build and install this package:\n\n- Clone this repository\n- ``./setup.py install``\n\nUsage\n=====\n\nQuick Start\n-----------\n\nIn order to authenticate with the Linode API, you will first need to create a\n`Linode Personal Access Token`_ with your desired account permissions.\n\nThe following code sample can help you quickly get started using this package.\n\n.. code-block:: python\n\n from linode_api4 import LinodeClient, Instance\n\n # Create a Linode API client\n client = LinodeClient(\"MY_PERSONAL_ACCESS_TOKEN\")\n\n # Create a new Linode\n new_linode, root_pass = client.linode.instance_create(\n ltype=\"g6-nanode-1\",\n region=\"us-southeast\",\n image=\"linode/ubuntu22.04\",\n label=\"my-ubuntu-linode\"\n )\n\n # Print info about the Linode\n print(\"Linode IP:\", new_linode.ipv4[0])\n print(\"Linode Root Password:\", root_pass)\n\n # List all Linodes on the account\n my_linodes = client.linode.instances()\n\n # Print the Label of every Linode on the account\n print(\"All Instances:\")\n for instance in my_linodes:\n print(instance.label)\n\n # List Linodes in the us-southeast region\n specific_linodes = client.linode.instances(\n Instance.region == \"us-southeast\"\n )\n\n # Print the label of each Linode in us-southeast\n print(\"Instances in us-southeast:\")\n for instance in specific_linodes:\n print(instance.label)\n\n # Delete the new instance\n new_linode.delete()\n\nCheck out the `Getting Started guide`_ for more details on getting started\nwith this library, or read `the docs`_ for more extensive documentation.\n\n.. _Linode Personal Access Token: https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/\n.. _Getting Started guide: http://linode_api4.readthedocs.io/en/latest/guides/getting_started.html\n.. _the docs: http://linode_api4.readthedocs.io/en/latest/index.html\n\nExamples\n--------\n\nSee the `Install on a Linode`_ example project for a simple use case demonstrating\nmany of the features of this library.\n\n.. _Install on a Linode: https://github.com/linode/linode_api4-python/tree/master/examples/install-on-linode\n\nContributing\n============\n\nTests\n-----\n\nTests live in the ``tests`` directory. When invoking tests, make sure you are\nin the root directory of this project. To run the full suite across all\nsupported python versions, use tox_:\n\n.. code-block:: shell\n\n tox\n\nRunning tox also runs pylint and coverage reports.\n\nThe test suite uses fixtures stored as JSON in ``test/fixtures``. These files\ncontain sanitized JSON responses from the API - the file name is the URL called\nto produce the response, replacing any slashes with underscores.\n\nTest classes should extend ``test.base.ClientBaseCase``. This provides them\nwith ``self.client``, a ``LinodeClient`` object that is set up to work with\ntests. Importantly, any GET request made by this object will be mocked to\nretrieve data from the test fixtures. This includes lazy-loaded objects using\nthis client (and by extension related models).\n\nWhen testing against requests other than GET requests, ``self.mock_post`` (and\nequivalent methods for other HTTP verbs) can be used in a ``with`` block to\nmock out the intended request type. These functions accept the relative path\nfrom the api base url that should be returned, for example::\n\n # this should return the result of GET /linode/instances/123\n with self.mock_post('/linode/instances/123'):\n linode = self.client.linode.instance_create('g6-standard-2', 'us-east')\n self.assertEqual(linode.id, 123) # passes\n\n.. _tox: http://tox.readthedocs.io\n\nDocumentation\n-------------\n\nThis library is documented with Sphinx_. Docs live in the ``docs`` directory.\nThe easiest way to build the docs is to run ``sphinx-autobuild`` in that\nfolder.\n\nClasses and functions inside the library should be annotated with sphinx-compliant\ndocstrings which will be used to automatically generate documentation for the\nlibrary. When contributing, be sure to update documentation or include new\ndocstrings where applicable to keep the library's documentation up to date\nand useful.\n\n**Missing or inaccurate documentation is a bug**. If you notice that the\ndocumentation for this library is out of date or unclear, please\n`open an issue`_ to make us aware of the problem.\n\n.. _Sphinx: http://www.sphinx-doc.org/en/master/index.html\n.. _open an issue: https://github.com/linode/linode_api4-python/issues/new\n\nContributing\n------------\n\nPlease follow the `Contributing Guidelines`_ when making a contribution.\n\n.. _Contributing Guidelines: https://github.com/linode/linode_api4-python/blob/master/CONTRIBUTING.md\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "The official python SDK for Linode API v4",
"version": "5.55.4",
"split_keywords": [
"linode",
"cloud",
"hosting",
"infrastructure"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "998a450a217e995b164e01846bf1efb3d875b0fad4e336e660a5f3bc2fef700a",
"md5": "665f9aa04496d7ba778dfbb7ea485596",
"sha256": "acd20188d9c27da62a1ad5d1485d3d2c4fff6ebed2635705196943e4e428e066"
},
"downloads": -1,
"filename": "linode_api4_testrelease-5.55.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "665f9aa04496d7ba778dfbb7ea485596",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 61316,
"upload_time": "2023-04-11T19:01:13",
"upload_time_iso_8601": "2023-04-11T19:01:13.999460Z",
"url": "https://files.pythonhosted.org/packages/99/8a/450a217e995b164e01846bf1efb3d875b0fad4e336e660a5f3bc2fef700a/linode_api4_testrelease-5.55.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a97e032779255c51db6b91e944edd4801b859a910e0e32c0c2feda7e665bf423",
"md5": "6775275e4f35371c9d3f27021b519301",
"sha256": "28d8d09fa1315847f3f3e71919129a4287238b99c2bb659c2f9e0ce65d1cb57b"
},
"downloads": -1,
"filename": "linode_api4-testrelease-5.55.4.tar.gz",
"has_sig": false,
"md5_digest": "6775275e4f35371c9d3f27021b519301",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 81042,
"upload_time": "2023-04-11T19:01:16",
"upload_time_iso_8601": "2023-04-11T19:01:16.107459Z",
"url": "https://files.pythonhosted.org/packages/a9/7e/032779255c51db6b91e944edd4801b859a910e0e32c0c2feda7e665bf423/linode_api4-testrelease-5.55.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-11 19:01:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "linode",
"github_project": "linode_api4-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "linode-api4-testrelease"
}