Package: linode-api4-testrelease
linode_api4The official python library for theLinode API v4in python.Installationpip install linode_api4Building from SourceTo build and install this package:Clone this repository./setup.py installUsageQuick StartIn order to authenticate with the Linode API, you will first need to create aLinode Personal Access Tokenwith your desired account permissions.The following code sample can help you quickly get started using this package.fromlinode_api4importLinodeClient,Instance# Create a Linode API clientclient=LinodeClient("MY_PERSONAL_ACCESS_TOKEN")# Create a new Linodenew_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 Linodeprint("Linode IP:",new_linode.ipv4[0])print("Linode Root Password:",root_pass)# List all Linodes on the accountmy_linodes=client.linode.instances()# Print the Label of every Linode on the accountprint("All Instances:")forinstanceinmy_linodes:print(instance.label)# List Linodes in the us-southeast regionspecific_linodes=client.linode.instances(Instance.region=="us-southeast")# Print the label of each Linode in us-southeastprint("Instances in us-southeast:")forinstanceinspecific_linodes:print(instance.label)# Delete the new instancenew_linode.delete()Check out theGetting Started guidefor more details on getting started
with this library, or readthe docsfor more extensive documentation.ExamplesSee theInstall on a Linodeexample project for a simple use case demonstrating
many of the features of this library.ContributingTestsTests live in thetestsdirectory.  When invoking tests, make sure you are
in the root directory of this project.  To run the full suite across all
supported python versions, usetox:toxRunning tox also runs pylint and coverage reports.The test suite uses fixtures stored as JSON intest/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 extendtest.base.ClientBaseCase.  This provides them
withself.client, aLinodeClientobject 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 awithblock 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) # passesDocumentationThis library is documented withSphinx.  Docs live in thedocsdirectory.
The easiest way to build the docs is to runsphinx-autobuildin 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, pleaseopen an issueto make us aware of the problem.ContributingPlease follow theContributing Guidelineswhen making a contribution.