linode_api4
The official python library for the Linode API v4 in python.
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.
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.
Examples
See the Install on a Linode example project for a simple use case demonstrating many of the features of this library.
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:
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
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.
Contributing
Please follow the Contributing Guidelines when making a contribution.
Metadata
Release files for linode-api4-testrelease 5.55.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linode_api4-testrelease-5.55.4.tar.gz | 81.0 kB | Without provenance | Details for linode_api4-testrelease-5.55.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linode_api4_testrelease-5.55.4-py3-none-any.whl | Python 3 | none | any | Details for linode_api4_testrelease-5.55.4-py3-none-any.whl |
Total release size: 142.4 kB
Release files / linode_api4-testrelease-5.55.4.tar.gz
| Download URL | linode_api4-testrelease-5.55.4.tar.gz |
|---|---|
| Size | 81.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28d8d09fa1315847f3f3e71919129a4287238b99c2bb659c2f9e0ce65d1cb57b
|
|
BLAKE2b-256 checksum How to use checksums |
a97e032779255c51db6b91e944edd4801b859a910e0e32c0c2feda7e665bf423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / linode_api4_testrelease-5.55.4-py3-none-any.whl
| Download URL | linode_api4_testrelease-5.55.4-py3-none-any.whl |
|---|---|
| Size | 61.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
acd20188d9c27da62a1ad5d1485d3d2c4fff6ebed2635705196943e4e428e066
|
|
BLAKE2b-256 checksum How to use checksums |
998a450a217e995b164e01846bf1efb3d875b0fad4e336e660a5f3bc2fef700a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for linode-api4-testrelease 5.55.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.