Linode Client

The LinodeClient is responsible for managing your connection to the API using your token. A LinodeClient is required for all connections to the API, and a reference to one is required by every model. A LinodeClient is created with a token, either an OAuth Token from the OAuth Exchange (see oauth for more information) or a Personal Access Token. See our getting_started guide for more information:

from linode_api4 import LinodeClient

token = "api-token" # your token goes here

client = LinodeClient(token)

Grouping

The LinodeClient class is divided into groups following the API’s overall design - some methods and functions are accessible only through members of the LinodeClient class:

# access an ungrouped member
client.regions() # /regions

# access a grouped member - note the URL matches the grouping
client.linode.instances() # /linode/instances

The LinodeClient itself holds top-level collections of the API, while anything that exists under a group in the API belongs to a member of the client.

LinodeClient class

class linode_api4.LinodeClient(token, base_url='https://api.linode.com/v4', user_agent=None, page_size=None, retry=True, retry_rate_limit_interval=1.0, retry_max=5, retry_statuses=None, ca_path=None)[source]
__init__(token, base_url='https://api.linode.com/v4', user_agent=None, page_size=None, retry=True, retry_rate_limit_interval=1.0, retry_max=5, retry_statuses=None, ca_path=None)[source]

The main interface to the Linode API.

Parameters:
  • token (str) – The authentication token to use for communication with the API. Can be either a Personal Access Token or an OAuth Token.

  • base_url (str) – The base URL for API requests. Generally, you shouldn’t change this.

  • user_agent (str) – What to append to the User Agent of all requests made by this client. Setting this allows Linode’s internal monitoring applications to track the usage of your application. Setting this is not necessary, but some applications may desire this behavior.

  • page_size (int) – The default size to request pages at. If not given, the API’s default page size is used. Valid values can be found in the API docs, but at time of writing are between 25 and 500.

  • retry (bool) – Whether API requests should automatically be retries on known intermittent responses.

  • retry_rate_limit_interval (Union[float, int]) – The amount of time to wait between HTTP request retries.

  • retry_max (int) – The number of request retries that should be attempted before raising an API error.

  • retry_statuses (List of int) – Additional HTTP response statuses to retry on. By default, the client will retry on 408, 429, and 502 responses.

  • ca_path (str) – The path to a CA file to use for API requests in this client.

account

Access methods related to your account - see AccountGroup for more information

beta

Access methods related to Beta Program - See BetaProgramGroup for more information.

database

Access methods related to Managed Databases - see DatabaseGroup for more information.

domain_create(domain, master=True, **kwargs)[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.domains.create(...) for all new projects.

domains

Access methods related to Domains - see DomainGroup for more information.

image_create(disk, label=None, description=None, tags=None)[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.images.create(...) for all new projects.

image_create_upload(label: str, region: str, description: str | None = None, tags: List[str] | None = None) Tuple[Image, str][source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.images.create_upload(...) for all new projects.

image_upload(label: str, region: str, file: BinaryIO, description: str | None = None, tags: List[str] | None = None) Image[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.images.upload(...) for all new projects.

images

Access methods related to Images - See ImageGroup for more information.

linode

Access methods related to Linodes - see LinodeGroup for more information

lke

Access methods related to LKE - see LKEGroup for more information.

locks

Access methods related to Resource Locks - See LockGroup for more information.

longview

Access information related to the Longview service - see LongviewGroup for more information

maintenance

Access methods related to maintenance on your account - see MaintenanceGroup for more information

networking

Access methods related to networking on your account - see NetworkingGroup for more information

nodebalancer_create(region, **kwargs)[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.nodebalancers.create(...) for all new projects.

nodebalancers

Access methods related to NodeBalancers - see NodeBalancerGroup for more information.

object_storage

Access methods related to Object Storage - see ObjectStorageGroup for more information

placement

Access methods related to VM placement - See PlacementAPIGroup for more information.

polling

Access methods related to Event polling - See PollingGroup for more information.

profile

Access methods related to your user - see ProfileGroup for more information

regions

Access methods related to Regions - See RegionGroup for more information.

sharegroups

Access methods related to Image Share Groups - See ImageShareGroupAPIGroup for more information.

support

Access methods related to support - see SupportGroup for more information

tag_create(label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=[])[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.tags.create(...) for all new projects.

tags

Access methods related to Tags - See TagGroup for more information.

volume_create(label, region=None, linode=None, size=20, **kwargs)[source]

Note

This method is an alias to maintain backwards compatibility. Please use LinodeClient.volumes.create(...) for all new projects.

volumes

Access methods related to Volumes - See VolumeGroup for more information.

vpcs

Access methods related to VPCs - See VPCGroup for more information.

Groups

These groups are accessed off of the LinodeClient class by name. For example:

client.linode.instances()

See LinodeClient for more information on the naming of these groups, although generally they are named the same as the first word of the group.

AccountGroup

Includes methods for managing your account.

class linode_api4.linode_client.AccountGroup(client: BaseClient)[source]

Collections related to your account.

__call__()[source]

Retrieves information about the acting user’s account, such as billing information. This is intended to be called off of the LinodeClient class, like this:

account = client.account()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-account

Returns:

Returns the acting user’s account information.

Return type:

Account

add_payment_method(data, is_default, type)[source]

Adds a Payment Method to your Account with the option to set it as the default method.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-payment-method

Parameters:

data (dict) – An object representing the credit card information you have on file with Linode to make Payments against your Account.

Example usage::
data = {

“card_number”: “4111111111111111”, “expiry_month”: 11, “expiry_year”: 2020, “cvv”: “111”

}

Parameters:
  • is_default (bool) – Whether this Payment Method is the default method for automatically processing service charges.

  • type (str) – The type of Payment Method. Enum: [“credit_card]

add_promo_code(promo_code)[source]

Adds an expiring Promo Credit to your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-promo-credit

Parameters:

promo_code (str) – The Promo Code.

availabilities(*filters)[source]

Returns a list of all available regions and the resource types which are available to the account.

API doc: https://techdocs.akamai.com/linode-api/reference/get-account-availability

Returns:

a list of region availability information.

Return type:

PaginatedList of AccountAvailability

child_accounts(*filters)[source]

Returns a list of all child accounts under the this parent account.

NOTE: Parent/Child related features may not be generally available.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-child-accounts

Returns:

a list of all child accounts.

Return type:

PaginatedList of ChildAccount

enrolled_betas(*filters)[source]

Returns a list of all Beta Programs an account is enrolled in.

API doc: https://techdocs.akamai.com/linode-api/reference/get-enrolled-beta-programs

Returns:

a list of Beta Programs.

Return type:

PaginatedList of AccountBetaProgram

events(*filters)[source]

Lists events on the current account matching the given filters.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-events

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of events on the current account matching the given filters.

Return type:

PaginatedList of Event

events_mark_seen(event)[source]

Marks event as the last event we have seen. If event is an int, it is treated as an event_id, otherwise it should be an event object whose id will be used.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-event-seen

Parameters:

event (Event or int) – The Linode event to mark as seen.

invoices(*filters)[source]

Returns Invoices issued to this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-invoices

Parameters:

filters – Any number of filters to apply to this query.

Returns:

Invoices issued to this account.

Return type:

PaginatedList of Invoice

join_beta_program(beta: str | BetaProgram)[source]

Enrolls an account into a beta program.

API doc: https://techdocs.akamai.com/linode-api/reference/post-beta-program

Parameters:

beta (BetaProgram or str) – The object or id of a beta program to join.

Returns:

A boolean indicating whether the account joined a beta program successfully.

Return type:

bool

linode_managed_enable()[source]

Enables Linode Managed for the entire account and sends a welcome email to the account’s associated email address.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-enable-account-managed

logins()[source]

Returns a collection of successful logins for all users on the account during the last 90 days.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-account-logins

Returns:

A list of Logins on this account.

Return type:

PaginatedList of Login

maintenance()[source]

Returns a collection of Maintenance objects for any entity a user has permissions to view. Cancelled Maintenance objects are not returned.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-maintenance

Returns:

A list of Maintenance objects on this account.

Return type:

List of Maintenance objects as MappedObjects

notifications()[source]

Returns a collection of Notification objects representing important, often time-sensitive items related to your Account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-notifications

Returns:

A list of Notifications on this account.

Return type:

List of Notification objects as MappedObjects

oauth_client_create(name, redirect_uri, **kwargs)[source]

Creates a new OAuth client.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-client

Parameters:
  • name (str) – The name of this application.

  • redirect_uri (str) – The location a successful log in from https://login.linode.com should be redirected to for this client.

Returns:

The created OAuth Client.

Return type:

OAuthClient

oauth_clients(*filters)[source]

Returns the OAuth Clients associated with this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-clients

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of OAuth Clients associated with this account.

Return type:

PaginatedList of OAuthClient

payment_methods()[source]

Returns a list of Payment Methods for this Account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-payment-methods

Returns:

A list of Payment Methods on this account.

Return type:

PaginatedList of PaymentMethod

payments(*filters)[source]

Returns a list of Payments made on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-payments

Returns:

A list of payments made on this account.

Return type:

PaginatedList of Payment

service_transfer_create(entities)[source]

Creates a transfer request for the specified services.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-service-transfer

Parameters:

entities (dict) – A collection of the services to include in this transfer request, separated by type.

Example usage::
entities = {
“linodes”: [

111, 222

]

}

service_transfers(*filters)[source]

Returns a collection of all created and accepted Service Transfers for this account, regardless of the user that created or accepted the transfer.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-service-transfers

Returns:

A list of Service Transfers on this account.

Return type:

PaginatedList of ServiceTransfer

settings()[source]

Returns the account settings data for this acocunt. This is not a listing endpoint.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-account-settings

Returns:

The account settings data for this account.

Return type:

AccountSettings

transfer()[source]

Returns a MappedObject containing the account’s transfer pool data.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-transfer

Returns:

Information about this account’s transfer pool data.

Return type:

MappedObject

user_create(email, username, restricted=True)[source]

Creates a new user on your account. If you create an unrestricted user, they will immediately be able to access everything on your account. If you create a restricted user, you must grant them access to parts of your account that you want to allow them to manage (see User.grants for details).

The new user will receive an email inviting them to set up their password. This must be completed before they can log in.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-user

Parameters:
  • email (str) – The new user’s email address. This is used to finish setting up their user account.

  • username (str) – The new user’s unique username. They will use this username to log in.

  • restricted (True) – If True, the new user must be granted access to parts of the account before they can do anything. If False, the new user will immediately be able to manage the entire account. Defaults to True.

:returns The new User. :rtype: User

users(*filters)[source]

Returns a list of users on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-users

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of users on this account.

Return type:

PaginatedList of User

BetaGroup

Includes methods for enrolling in beta programs.

DatabaseGroup

Includes methods for managing Linode Managed Databases.

class linode_api4.linode_client.DatabaseGroup(client: BaseClient)[source]

Encapsulates Linode Managed Databases related methods of the LinodeClient. This should not be instantiated on its own, but should instead be used through an instance of LinodeClient:

client = LinodeClient(token)
instances = client.database.instances() # use the DatabaseGroup

This group contains all features beneath the /databases group in the API v4.

engines(*filters)[source]

Returns a list of Linode Managed Database Engines. These may be used to create Managed Databases, or simply referenced to on their own. Engines can be filtered to return specific engines, for example:

mysql_engines = client.database.engines(DatabaseEngine.engine == 'mysql')

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-engines

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of types that match the query.

Return type:

PaginatedList of DatabaseEngine

instances(*filters)[source]

Returns a list of Managed Databases active on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-instances

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of databases that matched the query.

Return type:

PaginatedList of Database

mysql_config_options()[source]

Returns a detailed list of all the configuration options for MySQL Databases.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-mysql-config

Returns:

The JSON configuration options for MySQL Databases.

mysql_create(label, region, engine, ltype, engine_config: MySQLDatabaseConfigOptions | Dict[str, Any] = None, private_network: DatabasePrivateNetwork | Dict[str, Any] = None, **kwargs)[source]

Creates an MySQLDatabase on this account with the given label, region, engine, and node type. For example:

client = LinodeClient(TOKEN)

# look up Region and Types to use.  In this example I'm just using
# the first ones returned.
region = client.regions().first()
node_type = client.database.types()[0]
engine = client.database.engines(DatabaseEngine.engine == 'mysql')[0]

new_database = client.database.mysql_create(
    "example-database",
    region,
    engine.id,
    type.id
 )

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instances

Parameters:
  • label (str) – The name for this cluster

  • region (str or Region) – The region to deploy this cluster in

  • engine (str or Engine) – The engine to deploy this cluster with

  • ltype (str or Type) – The Linode Type to use for this cluster

  • engine_config (Dict[str, Any] or MySQLDatabaseConfigOptions) – The configuration options for this MySQL cluster

  • private_network (Dict[str, Any] or DatabasePrivateNetwork) – The private network settings to use for this cluster

mysql_fork(source, restore_time, **kwargs)[source]

Forks an MySQLDatabase on this account with the given restore_time. label, region, engine, and ltype are optional. For example:

client = LinodeClient(TOKEN)

db_to_fork = client.database.mysql_instances()[0]

new_fork = client.database.mysql_fork(
     db_to_fork.id,
     db_to_fork.updated,
     label="new-fresh-label"
)

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instances

Parameters:
  • source (int) – The id of the source database

  • restore_time (datetime) – The timestamp for the fork

  • label (str) – The name for this cluster

  • region (str | Region) – The region to deploy this cluster in

  • engine (str | Engine) – The engine to deploy this cluster with

  • ltype (str | Type) – The Linode Type to use for this cluster

mysql_instances(*filters)[source]

Returns a list of Managed MySQL Databases active on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-mysql-instances

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of MySQL databases that matched the query.

Return type:

PaginatedList of MySQLDatabase

postgresql_config_options()[source]

Returns a detailed list of all the configuration options for PostgreSQL Databases.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-postgresql-config

Returns:

The JSON configuration options for PostgreSQL Databases.

postgresql_create(label, region, engine, ltype, engine_config: PostgreSQLDatabaseConfigOptions | Dict[str, Any] = None, private_network: DatabasePrivateNetwork | Dict[str, Any] = None, **kwargs)[source]

Creates an PostgreSQLDatabase on this account with the given label, region, engine, and node type. For example:

client = LinodeClient(TOKEN)

# look up Region and Types to use.  In this example I'm just using
# the first ones returned.
region = client.regions().first()
node_type = client.database.types()[0]
engine = client.database.engines(DatabaseEngine.engine == 'postgresql')[0]

new_database = client.database.postgresql_create(
    "example-database",
    region,
    engine.id,
    type.id
 )

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-postgre-sql-instances

Parameters:
  • label (str) – The name for this cluster

  • region (str or Region) – The region to deploy this cluster in

  • engine (str or Engine) – The engine to deploy this cluster with

  • ltype (str or Type) – The Linode Type to use for this cluster

  • engine_config (Dict[str, Any] or PostgreSQLDatabaseConfigOptions) – The configuration options for this PostgreSQL cluster

  • private_network (Dict[str, Any] or DatabasePrivateNetwork) – The private network settings to use for this cluster

postgresql_fork(source, restore_time, **kwargs)[source]

Forks an PostgreSQLDatabase on this account with the given restore_time. label, region, engine, and ltype are optional. For example:

client = LinodeClient(TOKEN)

db_to_fork = client.database.postgresql_instances()[0]

new_fork = client.database.postgresql_fork(
     db_to_fork.id,
     db_to_fork.updated,
     label="new-fresh-label"
)

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-postgresql-instances

Parameters:
  • source (int) – The id of the source database

  • restore_time (datetime) – The timestamp for the fork

  • label (str) – The name for this cluster

  • region (str | Region) – The region to deploy this cluster in

  • engine (str | Engine) – The engine to deploy this cluster with

  • ltype (str | Type) – The Linode Type to use for this cluster

postgresql_instances(*filters)[source]

Returns a list of Managed PostgreSQL Databases active on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-postgre-sql-instances

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of PostgreSQL databases that matched the query.

Return type:

PaginatedList of PostgreSQLDatabase

types(*filters)[source]

Returns a list of Linode Database-compatible Instance types. These may be used to create Managed Databases, or simply referenced to on their own. DatabaseTypes can be filtered to return specific types, for example:

database_types = client.database.types(DatabaseType.deprecated == False)

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of types that match the query.

Return type:

PaginatedList of DatabaseType

DomainGroup

Includes methods for managing Linode Domains.

class linode_api4.linode_client.DomainGroup(client: BaseClient)[source]
__call__(*filters)[source]

Retrieves all of the Domains the acting user has access to.

This is intended to be called off of the LinodeClient class, like this:

domains = client.domains()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-domains

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Domains the acting user can access.

Return type:

PaginatedList of Domain

create(domain, master=True, **kwargs)[source]

Registers a new Domain on the acting user’s account. Make sure to point your registrar to Linode’s nameservers so that Linode’s DNS manager will correctly serve your domain.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-domain

Parameters:
  • domain (str) – The domain to register to Linode’s DNS manager.

  • master (bool) – Whether this is a master (defaults to true)

  • tags (list[str]) – A list of tags to apply to the new domain. If any of the tags included do not exist, they will be created as part of this operation.

Returns:

The new Domain object.

Return type:

Domain

ImageGroup

Includes methods for managing Linode Images.

class linode_api4.linode_client.ImageGroup(client: BaseClient)[source]
__call__(*filters)[source]

Retrieves a list of available Images, including public and private Images available to the acting user. You can filter this query to retrieve only Images relevant to a specific query, for example:

debian_images = client.images(
    Image.vendor == "debain")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-images

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of available Images.

Return type:

PaginatedList of Image

create(disk: Disk | int, label: str | None = None, description: str | None = None, cloud_init: bool = False, tags: List[str] | None = None)[source]

Creates a new Image from a disk you own.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-image

Parameters:
  • disk (Union[Disk, int]) – The Disk to imagize.

  • label (str) – The label for the resulting Image (defaults to the disk’s label.

  • description (str) – The description for the new Image.

  • cloud_init (bool) – Whether this Image supports cloud-init.

  • tags (Optional[List[str]]) – A list of customized tags of this new Image.

Returns:

The new Image.

Return type:

Image

create_upload(label: str, region: str, description: str | None = None, cloud_init: bool = False, tags: List[str] | None = None) Tuple[Image, str][source]

Creates a new Image and returns the corresponding upload URL.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-upload-image

Parameters:
  • label (str) – The label of the Image to create.

  • region (str) – The region to upload to. Once the image has been created, it can be used in any region.

  • description (str) – The description for the new Image.

  • cloud_init (bool) – Whether this Image supports cloud-init.

  • tags (Optional[List[str]]) – A list of customized tags of this Image.

Returns:

A tuple containing the new image and the image upload URL.

Return type:

(Image, str)

upload(label: str, region: str, file: BinaryIO, description: str | None = None, tags: List[str] | None = None) Image[source]

Creates and uploads a new image.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-upload-image

Parameters:
  • label (str) – The label of the Image to create.

  • region (str) – The region to upload to. Once the image has been created, it can be used in any region.

  • file – The BinaryIO object to upload to the image. This is generally obtained from open(“myfile”, “rb”).

  • description (str) – The description for the new Image.

  • tags (Optional[List[str]]) – A list of customized tags of this Image.

Returns:

The resulting image.

Return type:

Image

LinodeGroup

Includes methods for managing and creating Linode Instances, as well as accessing and working with associated features.

class linode_api4.linode_client.LinodeGroup(client: BaseClient)[source]

Encapsulates Linode-related methods of the LinodeClient. This should not be instantiated on its own, but should instead be used through an instance of LinodeClient:

client = LinodeClient(token)
instances = client.linode.instances() # use the LinodeGroup

This group contains all features beneath the /linode group in the API v4.

static build_instance_metadata(user_data=None, encode_user_data=True)[source]

Builds the contents of the metadata field to be passed into the instance_create method. This helper can also be used when cloning and rebuilding Instances. Creating an Instance with User Data:

new_linode = client.linode.instance_create(
    "g6-standard-2",
    "us-east",
    image="linode/ubuntu22.04",
    root_pass="aComplex@Password123",
    metadata=client.linode.build_instance_metadata(user_data="myuserdata")
)
Parameters:
  • user_data (str) – User-defined data to provide to the Linode Instance through the Metadata service.

  • encode_user_data (bool) – If true, the provided user_data field will be automatically encoded to a valid base64 string. This field should only be set to false if the user_data param is already base64-encoded.

Returns:

The built metadata structure.

Return type:

dict

instance_create(ltype, region, image=None, authorized_keys=None, firewall: Firewall | int | None = None, backup: Backup | int | None = None, stackscript: StackScript | int | None = None, disk_encryption: InstanceDiskEncryptionType | str | None = None, placement_group: InstancePlacementGroupAssignment | PlacementGroup | Dict[str, Any] | int | None = None, interfaces: List[LinodeInterfaceOptions | NetworkInterface | Dict[str, Any]] | None = None, interface_generation: InterfaceGeneration | str | None = None, network_helper: bool | None = None, maintenance_policy: str | None = None, root_pass: str | None = None, kernel: str | None = None, boot_size: int | None = None, authorized_users: List[str] | None = None, ipv4: List[str] | None = None, **kwargs)[source]

Creates a new Linode Instance. This function has several modes of operation:

Create an Instance from an Image

To create an Instance from an Image, call instance_create with a Type, a Region, and an Image. All three of these fields may be provided as either the ID or the appropriate object. When an Image is provided, at least one of root_pass, authorized_users, or authorized_keys must also be given.

For example:

new_linode = client.linode.instance_create(
    "g6-standard-2",
    "us-east",
    image="linode/debian13",
    root_pass="aComplex@Password123")

ltype = client.linode.types().first()
region = client.regions().first()
image = client.images().first()

another_linode = client.linode.instance_create(
    ltype,
    region,
    image=image,
    authorized_keys="ssh-rsa AAAA")
To output the first IPv4 address of the new Linode:

print(new_linode.ipv4[0])

To delete the new_linode (WARNING: this immediately destroys the Linode):

new_linode.delete()

Create an Instance from StackScript

When creating an Instance from a StackScript, an Image that the StackScript support must be provided.. You must also provide any required StackScript data for the script’s User Defined Fields.. For example, if deploying StackScript 10079 (which deploys a new Instance with a user created from keys on github:

stackscript = StackScript(client, 10079)

new_linode = client.linode.instance_create(
   "g6-standard-2",
   "us-east",
   image="linode/debian13",
   root_pass="aComplex@Password123",
   stackscript=stackscript,
   stackscript_data={"gh_username": "example"})

In the above example, “gh_username” is the name of a User Defined Field in the chosen StackScript. For more information on StackScripts, see the StackScript guide.

Create an Instance from a Backup

To create a new Instance by restoring a Backup to it, provide a Type, a Region, and the Backup to restore. You may provide either IDs or objects for all of these fields:

existing_linode = Instance(client, 123)
snapshot = existing_linode.available_backups.snapshot.current

new_linode = client.linode.instance_create(
    "g6-standard-2",
    "us-east",
    backup=snapshot)

Create an Instance with explicit interfaces:

To create a new Instance with explicit interfaces, provide list of LinodeInterfaceOptions objects or dicts to the “interfaces” field:

linode = client.linode.instance_create(

“g6-standard-1”, “us-mia”, image=”linode/ubuntu24.04”, root_pass=”aComplex@Password123”,

# This can be configured as an account-wide default interface_generation=InterfaceGeneration.LINODE,

interfaces=[
LinodeInterfaceOptions(
default_route=LinodeInterfaceDefaultRouteOptions(

ipv4=True, ipv6=True

), public=LinodeInterfacePublicOptions

)

]

)

Create an empty Instance

If you want to create an empty Instance that you will configure manually, simply call instance_create with a Type and a Region:

empty_linode = client.linode.instance_create("g6-standard-2", "us-east")

When created this way, the Instance will not be booted and cannot boot successfully until disks and configs are created, or it is otherwise configured.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-linode-instance

Parameters:
  • ltype (str or Type) – The Instance Type we are creating

  • region (str or Region) – The Region in which we are creating the Instance

  • image (str or Image) – The Image to deploy to this Instance. If this is provided, at least one of root_pass, authorized_users, or authorized_keys must also be provided.

  • root_pass (str) – The root password for the new Instance. Required when an image is provided and neither authorized_users nor authorized_keys are given.

  • stackscript (int or StackScript) – The StackScript to deploy to the new Instance. If provided, “image” is required and must be compatible with the chosen StackScript.

  • stackscript_data (dict) – Values for the User Defined Fields defined in the chosen StackScript. Does nothing if StackScript is not provided.

  • backup (int of Backup) – The Backup to restore to the new Instance. May not be provided if “image” is given.

  • authorized_keys (list or str) – The ssh public keys to install in the linode’s /root/.ssh/authorized_keys file. Each entry may be a single key, or a path to a file containing the key.

  • authorized_users (list[str]) – A list of usernames whose keys should be installed as trusted for the root user. These user’s keys should already be set up, see ProfileGroup.ssh_keys for details.

  • label (str) – The display label for the new Instance

  • group (str) – The display group for the new Instance

  • booted (bool) – Whether the new Instance should be booted. This will default to True if the Instance is deployed from an Image or Backup.

  • tags (list[str]) – A list of tags to apply to the new instance. If any of the tags included do not exist, they will be created as part of this operation.

  • private_ip (bool) – Whether the new Instance should have private networking enabled and assigned a private IPv4 address.

  • metadata (dict) – Metadata-related fields to use when creating the new Instance. The contents of this field can be built using the build_instance_metadata method.

  • firewall (int or Firewall) – The firewall to attach this Linode to.

  • disk_encryption (InstanceDiskEncryptionType or str) – The disk encryption policy for this Linode.

  • interfaces (List[LinodeInterfaceOptions], List[NetworkInterface], or List[dict[str, Any]]) – An array of Network Interfaces to add to this Linode’s Configuration Profile. At least one and up to three Interface objects can exist in this array.

  • placement_group (Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]) – A Placement Group to create this Linode under.

  • interface_generation (InterfaceGeneration or str) – The generation of network interfaces this Linode uses.

  • network_helper (bool) – Whether this instance should have Network Helper enabled.

  • maintenance_policy (str) – The slug of the maintenance policy to apply during maintenance. If not provided, the default policy (linode/migrate) will be applied.

  • kernel (str) – The kernel to boot the Instance with. If provided, this will be used as the kernel for the default configuration profile.

  • boot_size (int) – The size of the boot disk in MB. If provided, this will be used to create the boot disk for the Instance.

  • ipv4 (list[str]) – A list of reserved IPv4 addresses to assign to this Instance. NOTE: Reserved IP feature may not currently be available to all users.

Returns:

A new Instance object

Return type:

Instance

Raises:
  • ApiError – If contacting the API fails

  • UnexpectedResponseError – If the API response is somehow malformed. This usually indicates that you are using an outdated library.

instances(*filters)[source]

Returns a list of Linode Instances on your account. You may filter this query to return only Linodes that match specific criteria:

prod_linodes = client.linode.instances(Instance.group == "prod")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-linode-instances

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Instances that matched the query.

Return type:

PaginatedList of Instance

kernels(*filters)[source]

Returns a list of available Kernels. Kernels are used when creating or updating LinodeConfigs,LinodeConfig>.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-kernels

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of available kernels that match the query.

Return type:

PaginatedList of Kernel

stackscript_create(label, script, images, desc=None, public=False, **kwargs)[source]

Creates a new StackScript on your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-add-stack-script

Parameters:
  • label (str) – The label for this StackScript.

  • script (str) – The script to run when an Instance is deployed with this StackScript. Must begin with a shebang (#!).

  • images (list of Image) – A list of Images that this StackScript supports. Instances will not be deployed from this StackScript unless deployed from one of these Images.

  • desc (str) – A description for this StackScript.

  • public (bool) – Whether this StackScript is public. Defaults to False. Once a StackScript is made public, it may not be set back to private.

Returns:

The new StackScript

Return type:

StackScript

stackscripts(*filters, **kwargs)[source]

Returns a list of StackScripts, both public and private. You may filter this query to return only StackScripts that match certain criteria. You may also request only your own private StackScripts:

my_stackscripts = client.linode.stackscripts(mine_only=True)

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-stack-scripts

Parameters:
  • filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

  • mine_only (bool) – If True, returns only private StackScripts

Returns:

A list of StackScripts matching the query.

Return type:

PaginatedList of StackScript

types(*filters)[source]

Returns a list of Linode Instance types. These may be used to create or resize Linodes, or simply referenced on their own. Types can be filtered to return specific types, for example:

standard_types = client.linode.types(Type.class == "standard")

API documentation: https://techdocs.akamai.com/linode-api/reference/get-linode-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of types that match the query.

Return type:

PaginatedList of Type

LKEGroup

Includes methods for interacting with Linode Kubernetes Engine.

class linode_api4.linode_client.LKEGroup(client: BaseClient)[source]

Encapsulates LKE-related methods of the LinodeClient. This should not be instantiated on its own, but should instead be used through an instance of LinodeClient:

client = LinodeClient(token)
instances = client.lke.clusters() # use the LKEGroup

This group contains all features beneath the /lke group in the API v4.

cluster_create(region, label, kube_version, node_pools: list | None = None, control_plane: LKEClusterControlPlaneOptions | Dict[str, Any] = None, apl_enabled: bool = False, tier: str | None = None, **kwargs)[source]

Creates an LKECluster on this account in the given region, with the given label, and with node pools as described. For example:

client = LinodeClient(TOKEN)

# look up Region and Types to use.  In this example I'm just using
# the first ones returned.
target_region = client.regions().first()
node_type = client.linode.types()[0]
node_type_2 = client.linode.types()[1]
kube_version = client.lke.versions()[0]

new_cluster = client.lke.cluster_create(
    target_region,
    "example-cluster",
    [client.lke.node_pool(node_type, 3), client.lke.node_pool(node_type_2, 3)],
    kube_version
 )

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-lke-cluster

Parameters:
  • region (Region or str) – The Region to create this LKE Cluster in.

  • label (str) – The label for the new LKE Cluster.

  • node_pools (one or a list of dicts containing keys “type” and “count”. See node_pool for a convenient way to create correctly- formatted dicts.) – The Node Pools to create.

  • kube_version (KubeVersion or str) – The version of Kubernetes to use

  • control_plane (Dict[str, Any] or LKEClusterControlPlaneRequest) – The control plane configuration of this LKE cluster.

  • apl_enabled (bool) – Whether this cluster should use APL. NOTE: This field is in beta and may only function if base_url is set to https://api.linode.com/v4beta.

  • tier (str) – The tier of LKE cluster to create. NOTE: This field is in beta and may only function if base_url is set to https://api.linode.com/v4beta.

  • kwargs – Any other arguments to pass along to the API. See the API docs for possible values.

Returns:

The new LKE Cluster

Return type:

LKECluster

clusters(*filters)[source]

Returns a PaginagtedList of LKECluster objects that belong to this account.

https://techdocs.akamai.com/linode-api/reference/get-lke-clusters

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of LKE clusters that match the query.

Return type:

PaginatedList of LKECluster

node_pool(node_type: Type | str, node_count: int, **kwargs)[source]

Returns a dict that is suitable for passing into the node_pools array of cluster_create. This is a convenience method, and need not be used to create Node Pools. For proper usage, see the docs for cluster_create.

Parameters:
  • node_type (Type or str) – The type of node to create in this node pool.

  • node_count (int) – The number of nodes to create in this node pool.

  • kwargs (Any) – Other attributes to create this node pool with.

Returns:

A dict describing the desired node pool.

Return type:

dict

tier(id: str) LKETierGroup[source]

Returns an object representing the LKE tier API path.

NOTE: LKE tiers may not currently be available to all users.

Parameters:

id (str) – The ID of the tier.

Returns:

An object representing the LKE tier API path.

Return type:

LKETier

types(*filters)[source]

Returns a PaginatedList of LKEType objects that represents a valid LKE type.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lke-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of LKE types that match the query.

Return type:

PaginatedList of LKEType

versions(*filters)[source]

Returns a PaginatedList of KubeVersion objects that can be used when creating an LKE Cluster.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lke-versions

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of kube versions that match the query.

Return type:

PaginatedList of KubeVersion

LongviewGroup

Includes methods for interacting with our Longview service.

class linode_api4.linode_client.LongviewGroup(client: BaseClient)[source]

Collections related to Linode Longview.

client_create(label=None)[source]

Creates a new LongviewClient, optionally with a given label.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-longview-client

Parameters:

label – The label for the new client. If None, a default label based on the new client’s ID will be used.

Returns:

A new LongviewClient

Raises:
  • ApiError – If a non-200 status code is returned

  • UnexpectedResponseError – If the returned data from the api does not look as expected.

clients(*filters)[source]

Requests and returns a paginated list of LongviewClients on your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-longview-clients

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Longview Clients matching the given filters.

Return type:

PaginatedList of LongviewClient

longview_plan_update(longview_subscription)[source]

Update your Longview plan to that of the given subcription ID.

Parameters:

longview_subscription (str) – The subscription ID for a particular Longview plan. A value of null corresponds to Longview Free.

Returns:

The updated Longview Plan

Return type:

LongviewPlan

subscriptions(*filters)[source]

Requests and returns a paginated list of LongviewSubscriptions available

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-longview-subscriptions

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Longview Subscriptions matching the given filters.

Return type:

PaginatedList of LongviewSubscription

LockGroup

Includes methods for interacting with our Lock service.

class linode_api4.linode_client.LockGroup(client: BaseClient)[source]

Encapsulates methods for interacting with Resource Locks.

Resource locks prevent deletion or modification of resources. Currently, only Linode instances can be locked.

__call__(*filters)[source]

Returns a list of all Resource Locks on the account.

This is intended to be called off of the LinodeClient class, like this:

locks = client.locks()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-resource-locks

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Resource Locks on the account.

Return type:

PaginatedList of Lock

create(entity_type: str, entity_id: int | str, lock_type: LockType | str) Lock[source]

Creates a new Resource Lock for the specified entity.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-resource-lock

Parameters:
  • entity_type (str) – The type of entity to lock (e.g., “linode”).

  • entity_id (int | str) – The ID of the entity to lock.

  • lock_type (LockType | str) – The type of lock to create. Defaults to “cannot_delete”.

Returns:

The newly created Resource Lock.

Return type:

Lock

NetworkingGroup

Includes methods for managing your networking systems.

class linode_api4.linode_client.NetworkingGroup(client: BaseClient)[source]

Collections related to Linode Networking.

delete_vlan(vlan, region)[source]

This operation deletes a VLAN. You can’t delete a VLAN if it’s still attached to a Linode.

API Documentation: https://techdocs.akamai.com/linode-api/reference/delete-vlan

Parameters:
  • vlan (str or VLAN) – The label of the VLAN to be deleted.

  • region (str or Region) – The VLAN’s region.

firewall_create(label: str, rules: Dict[str, Any], devices: FirewallCreateDevicesOptions | Dict[str, Any] | None = None, **kwargs)[source]

Creates a new Firewall, either in the given Region or attached to the given Instance.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-firewalls

Parameters:
  • label (str) – The label for the new Firewall.

  • rules (dict) – The rules to apply to the new Firewall. For more information on Firewall rules, see our Firewalls Documentation.

  • devices (Optional[Union[FirewallCreateDevicesOptions, Dict[str, Any]]]) – Represents devices to create created alongside a Linode Firewall.

Returns:

The new Firewall.

Return type:

Firewall

Example usage:

rules = {
     'outbound': [
         {
             'action': 'ACCEPT',
             'addresses': {
                 'ipv4': [
                     '0.0.0.0/0'
                 ],
                 'ipv6': [
                     "ff00::/8"
                 ]
             },
             'description': 'Allow HTTP out.',
             'label': 'allow-http-out',
             'ports': '80',
             'protocol': 'TCP'
         }
     ],
     'outbound_policy': 'DROP',
     'inbound': [],
     'inbound_policy': 'DROP'
 }

 firewall = client.networking.firewall_create('my-firewall', rules)
firewall_settings() FirewallSettings[source]

Returns an object representing the Linode Firewall settings for the current user.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-firewall-settings

NOTE: This feature may not currently be available to all users. :returns: An object representing the Linode Firewall settings for the current user. :rtype: FirewallSettings

firewall_templates(*filters)[source]

Returns a list of Firewall Templates available to the current user.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-firewall-templates

NOTE: This feature may not currently be available to all users.

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Firewall Templates available to the current user.

Return type:

PaginatedList of FirewallTemplate

firewalls(*filters)[source]

Retrieves the Firewalls your user has access to.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-firewalls

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Firewalls the acting user can access.

Return type:

PaginatedList of Firewall

ip_addresses_assign(assignments, region)[source]

Assign multiple IPv4 addresses and/or IPv6 ranges to multiple Linodes in one Region. This allows swapping, shuffling, or otherwise reorganizing IPs to your Linodes.

The following restrictions apply:
  • All Linodes involved must have at least one public IPv4 address after assignment.

  • Linodes may have no more than one assigned private IPv4 address.

  • Linodes may have no more than one assigned IPv6 range.

Parameters:
  • region (str or Region) – The Region in which the assignments should take place. All Instances and IPAddresses involved in the assignment must be within this region.

  • assignments (list) – Any number of assignments to make. See IPAddress.to for details on how to construct assignments.

ip_addresses_share(ips, linode)[source]

Configure shared IPs. IP sharing allows IP address reassignment (also referred to as IP failover) from one Linode to another if the primary Linode becomes unresponsive. This means that requests to the primary Linode’s IP address can be automatically rerouted to secondary Linodes at the configured shared IP addresses.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-share-ips

Parameters:
  • linode – The id of the Instance or the Instance to share the IPAddresses with. This Instance will be able to bring up the given addresses.

  • ips (str or IPAddress) – Any number of IPAddresses to share to the Instance. Enter an empty array to remove all shared IP addresses.

Type:

linode: int or Instance

ip_allocate(linode: Instance | int | None = None, public: bool = True, reserved: bool = False, region: Region | str | None = None) IPAddress[source]

Allocates an IP to an Instance you own, or reserves a new IP address.

When reserved is False (default), linode is required and an ephemeral IP is allocated and assigned to that Instance.

When reserved is True, either region or linode must be provided. Passing only region creates an unassigned reserved IP. Passing linode (with or without region) creates a reserved IP in the Instance’s region and assigns it to that Instance.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-allocate-ip

Parameters:
  • linode (Instance or int) – The Instance to allocate the new IP for.

  • public (bool) – If True, allocate a public IP address. Defaults to True.

  • reserved (bool) – If True, reserve the new IP address. NOTE: Reserved IP feature may not currently be available to all users.

  • region (str or Region) – The region for the reserved IP (required when reserved=True and linode is not set). NOTE: Reserved IP feature may not currently be available to all users.

Returns:

The new IPAddress.

Return type:

IPAddress

ips(*filters)[source]

Returns a list of IP addresses on this account, excluding private addresses.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-ips

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of IP addresses on this account.

Return type:

PaginatedList of IPAddress

ips_assign(region, *assignments)[source]

Redistributes IP Addressees within a single region. This function takes a Region and a list of assignments to make, then requests that the assignments take place. If any Instance ends up without a public IP, or with more than one private IP, all of the assignments will fail.

Note

This function does not update the local Linode Instance objects when called. In order to see the new addresses on the local instance objects, be sure to invalidate them with invalidate() after this completes.

Example usage:

linode1 = Instance(client, 123)
linode2 = Instance(client, 456)

# swap IPs between linodes 1 and 2
client.networking.assign_ips(linode1.region,
                             linode1.ips.ipv4.public[0].to(linode2),
                             linode2.ips.ipv4.public[0].to(linode1))

# make sure linode1 and linode2 have updated ipv4 and ips values
linode1.invalidate()
linode2.invalidate()

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-assign-ipv4s

Parameters:
  • region (str or Region) – The Region in which the assignments should take place. All Instances and IPAddresses involved in the assignment must be within this region.

  • assignments (dct) – Any number of assignments to make. See IPAddress.to for details on how to construct assignments.

DEPRECATED: Use ip_addresses_assign() instead

ips_share(linode, *ips)[source]

Shares the given list of IPAddresses with the provided Instance. This will enable the provided Instance to bring up the shared IP Addresses even though it does not own them.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-share-ipv4s

Parameters:
  • linode – The Instance to share the IPAddresses with. This Instance will be able to bring up the given addresses.

  • ips (str or IPAddress) – Any number of IPAddresses to share to the Instance.

Type:

linode: int or Instance

DEPRECATED: Use ip_addresses_share() instead

ipv6_pools(*filters)[source]

Returns a list of IPv6 pools on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-ipv6-pools

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of IPv6 pools on this account.

Return type:

PaginatedList of IPv6Pool

ipv6_range_allocate(prefix_length: int, route_target: str | None = None, linode: Instance | int | None = None, **kwargs) IPv6Range[source]

Creates an IPv6 Range and assigns it based on the provided Linode or route target IPv6 SLAAC address.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-ipv6-range

Create an IPv6 range assigned to a Linode by ID:

range = client.networking.ipv6_range_allocate(64, linode_id=123)

Create an IPv6 range assigned to a Linode by SLAAC:

range = client.networking.ipv6_range_allocate(
    64,
    route_target=instance.ipv6.split("/")[0]
)
Parameters:
  • prefix_length (int) – The prefix length of the IPv6 range.

  • route_target (str) – The IPv6 SLAAC address to assign this range to. Required if linode is not specified.

  • linode (Instance or int) – The ID of the Linode to assign this range to. The SLAAC address for the provided Linode is used as the range’s route_target. Required if linode is not specified.

Returns:

The new IPAddress.

Return type:

IPAddress

ipv6_ranges(*filters)[source]

Returns a list of IPv6 ranges on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-ipv6-ranges

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of IPv6 ranges on this account.

Return type:

PaginatedList of IPv6Range

reserved_ip_create(region: Region | str, tags: List[str] | None = None, **kwargs) ReservedIPAddress[source]

Reserves a new IPv4 address in the given region.

NOTE: Reserved IP feature may not currently be available to all users.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-reserved-ip

Parameters:
  • region (str or Region) – The region in which to reserve the IP.

  • tags (list of str) – Tags to apply to the reserved IP.

Returns:

The new reserved IP address.

Return type:

ReservedIPAddress

reserved_ip_types(*filters) PaginatedList[source]

Returns a list of reserved IP types with pricing information.

NOTE: Reserved IP feature may not currently be available to all users.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-reserved-ip-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of reserved IP types.

Return type:

PaginatedList of ReservedIPType

reserved_ips(*filters) PaginatedList[source]

Returns a list of reserved IPv4 addresses on your account.

NOTE: Reserved IP feature may not currently be available to all users.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-reserved-ips

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of reserved IP addresses on the account.

Return type:

PaginatedList of ReservedIPAddress

transfer_prices(*filters)[source]

Returns a PaginatedList of NetworkTransferPrice objects that represents a valid network transfer price.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-network-transfer-prices

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of network transfer price that match the query.

Return type:

PaginatedList of NetworkTransferPrice

vlans(*filters)[source]

Note

This endpoint is in beta. This will only function if base_url is set to https://api.linode.com/v4beta.

Returns a list of VLANs on your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-vlans

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A List of VLANs on your account.

Return type:

PaginatedList of VLAN

NodeBalancerGroup

Includes methods for managing Linode NodeBalancers.

class linode_api4.linode_client.NodeBalancerGroup(client: BaseClient)[source]
__call__(*filters)[source]

Retrieves all of the NodeBalancers the acting user has access to.

This is intended to be called off of the LinodeClient class, like this:

nodebalancers = client.nodebalancers()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-node-balancers

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of NodeBalancers the acting user can access.

Return type:

PaginatedList of NodeBalancers

create(region, **kwargs)[source]

Creates a new NodeBalancer in the given Region.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-node-balancer

Parameters:
  • region (Region or str) – The Region in which to create the NodeBalancer.

  • ipv4 (str) – A reserved IPv4 address to assign to this NodeBalancer. NOTE: Reserved IP feature may not currently be available to all users.

Returns:

The new NodeBalancer

Return type:

NodeBalancer

types(*filters)[source]

Returns a PaginatedList of NodeBalancerType objects that represents a valid NodeBalancer type.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-node-balancer-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of NodeBalancer types that match the query.

Return type:

PaginatedList of NodeBalancerType

ObjectStorageGroup

Includes methods for interacting with Linode Objects Storage. For interacting with buckets and objects, use the s3 API directly with a library like boto3.

class linode_api4.linode_client.ObjectStorageGroup(client: BaseClient)[source]

This group encapsulates all endpoints under /object-storage, including viewing available clusters, buckets, and managing keys and TLS/SSL certs, etc.

classmethod bucket_access(cluster_or_region: str, bucket_name: str, permissions: str | ObjectStorageKeyPermission)[source]

Returns a dict formatted to be included in the bucket_access argument of keys_create. See the docs for that method for an example of usage.

Parameters:
  • cluster_or_region (str) – The region or Object Storage cluster to grant access in.

  • bucket_name (str) – The name of the bucket to grant access to.

  • permissions (Union[str, ObjectStorageKeyPermission]) – The permissions to grant. Should be one of “read_only” or “read_write”.

  • use_region (bool) – Whether to use region mode.

Returns:

A dict formatted correctly for specifying bucket access for new keys.

Return type:

dict

bucket_create(cluster_or_region: str | ObjectStorageCluster, label: str, acl: ObjectStorageACL = ObjectStorageACL.PRIVATE, cors_enabled=False, s3_endpoint: str | None = None, endpoint_type: ObjectStorageEndpointType | None = None)[source]

Creates an Object Storage Bucket in the specified cluster. Accounts with negative balances cannot access this command. If the bucket already exists and is owned by you, this endpoint returns a 200 response with that bucket as if it had just been created.

This endpoint is available for convenience. It is recommended that instead you use the more fully-featured S3 API directly.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-object-storage-bucket

Parameters:
  • acl (str Enum: private,public-read,authenticated-read,public-read-write) – The Access Control Level of the bucket using a canned ACL string. For more fine-grained control of ACLs, use the S3 API directly.

  • cluster (str) – The ID of the Object Storage Cluster where this bucket should be created.

  • endpoint_type (str Enum: E0,E1,E2,E3) – The type of s3_endpoint available to the active user in this region.

  • s3_endpoint (str) – The active user’s s3 endpoint URL, based on the endpoint_type and region.

  • cors_enabled (bool) – If true, the bucket will be created with CORS enabled for all origins. For more fine-grained controls of CORS, use the S3 API directly.

  • label (str) – The name for this bucket. Must be unique in the cluster you are creating the bucket in, or an error will be returned. Labels will be reserved only for the cluster that active buckets are created and stored in. If you want to reserve this bucket’s label in another cluster, you must create a new bucket with the same label in the new cluster.

Returns:

A Object Storage Buckets that created by user.

Return type:

ObjectStorageBucket

buckets(*filters)[source]

Returns a paginated list of all Object Storage Buckets that you own. This endpoint is available for convenience. It is recommended that instead you use the more fully-featured S3 API directly.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-buckets

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Object Storage Buckets that matched the query.

Return type:

PaginatedList of ObjectStorageBucket

buckets_in_region(region: str, *filters)[source]

Returns a list of Buckets in the region belonging to this Account.

This endpoint is available for convenience. It is recommended that instead you use the more fully-featured S3 API directly.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-bucketin-cluster

Parameters:
  • filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

  • region (str) – The ID of an object storage region (e.g. us-mia-1).

Returns:

A list of Object Storage Buckets that in the requested cluster.

Return type:

PaginatedList of ObjectStorageBucket

cancel()[source]

Cancels Object Storage service. This may be a destructive operation. Once cancelled, you will no longer receive the transfer for or be billed for Object Storage, and all keys will be invalidated.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-cancel-object-storage

clusters(*filters)[source]

This endpoint will be deprecated to use the regions list API to list available OBJ clusters, and a new access key API will directly expose the S3 endpoint hostname.

Returns a list of available Object Storage Clusters. You may filter this query to return only Clusters that are available in a specific region:

us_east_clusters = client.object_storage.clusters(ObjectStorageCluster.region == "us-east")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-clusters

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Object Storage Clusters that matched the query.

Return type:

PaginatedList of ObjectStorageCluster

endpoints(*filters) PaginatedList[source]

Returns a paginated list of all Object Storage endpoints available in your account.

This is intended to be called from the LinodeClient class, like this:

endpoints = client.object_storage.endpoints()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-endpoints

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Object Storage Endpoints that matched the query.

Return type:

PaginatedList of ObjectStorageEndpoint

global_quotas(*filters)[source]

Lists the active account-level Object Storage quotas applied to your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-global-quotas

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of account-level Object Storage Quotas that matched the query.

Return type:

PaginatedList of ObjectStorageGlobalQuota

keys(*filters)[source]

Returns a list of Object Storage Keys active on this account. These keys allow third-party applications to interact directly with Linode Object Storage.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-keys

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Object Storage Keys that matched the query.

Return type:

PaginatedList of ObjectStorageKeys

keys_create(label: str, bucket_access: dict | List[dict] | None = None, regions: List[str] | None = None)[source]

Creates a new Object Storage keypair that may be used to interact directly with Linode Object Storage in third-party applications. This response is the only time that “secret_key” will be populated - be sure to capture its value or it will be lost forever.

If given, bucket_access will cause the new keys to be restricted to only the specified level of access for the specified buckets. For example, to create a keypair that can only access the “example” bucket in all clusters (and assuming you own that bucket in every cluster), you might do this:

client = LinodeClient(TOKEN)

# look up clusters
all_clusters = client.object_storage.clusters()

new_keys = client.object_storage.keys_create(
    "restricted-keys",
    bucket_access=[
        client.object_storage.bucket_access(cluster, "example", "read_write")
        for cluster in all_clusters
    ],
)

To create a keypair that can only read from the bucket “example2” in the “us-east-1” cluster (an assuming you own that bucket in that cluster), you might do this:

client = LinodeClient(TOKEN)
new_keys_2 = client.object_storage.keys_create(
    "restricted-keys-2",
    bucket_access=client.object_storage.bucket_access("us-east-1", "example2", "read_only"),
)

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-object-storage-keys

Parameters:
  • label (str) – The label for this keypair, for identification only.

  • bucket_access (Optional[Union[dict, List[dict]]]) – One or a list of dicts with keys “cluster,” “region”, “permissions”, and “bucket_name”. “cluster” key is deprecated because multiple cluster can be placed in the same region. Please consider switching to regions. If given, the resulting Object Storage keys will only have the requested level of access to the requested buckets, if they exist and are owned by you. See the provided bucket_access function for a convenient way to create these dicts.

Returns:

The new keypair, with the secret key populated.

Return type:

ObjectStorageKeys

object_url_create(cluster_or_region_id, bucket, method, name, content_type=None, expires_in=3600)[source]

Creates a pre-signed URL to access a single Object in a bucket. This can be used to share objects, and also to create/delete objects by using the appropriate HTTP method in your request body’s method parameter.

This endpoint is available for convenience. It is recommended that instead you use the more fully-featured S3 API directly.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-object-storage-object-url

Parameters:
  • cluster_or_region_id (str) – The ID of the cluster or region this bucket exists in.

  • bucket (str) – The bucket name.

  • content_type (str) – The expected Content-type header of the request this signed URL will be valid for. If provided, the Content-type header must be sent with the request when this URL is used, and must be the same as it was when the signed URL was created. Required for all methods except “GET” or “DELETE”.

  • expires_in (int 360..86400) – How long this signed URL will be valid for, in seconds. If omitted, the URL will be valid for 3600 seconds (1 hour). Defaults to 3600.

  • method (str) – The HTTP method allowed to be used with the pre-signed URL.

  • name (str) – The name of the object that will be accessed with the pre-signed URL. This object need not exist, and no error will be returned if it doesn’t. This behavior is useful for generating pre-signed URLs to upload new objects to by setting the method to “PUT”.

Returns:

The signed URL to perform the request at.

Return type:

MappedObject

quotas(*filters)[source]

Lists the active ObjectStorage-related quotas applied to your account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-quotas

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Object Storage Quotas that matched the query.

Return type:

PaginatedList of ObjectStorageQuota

transfer()[source]

The amount of outbound data transfer used by your account’s Object Storage buckets, in bytes, for the current month’s billing cycle. Object Storage adds 1 terabyte of outbound data transfer to your data transfer pool.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-transfer

Returns:

The amount of outbound data transfer used by your account’s Object Storage buckets, in bytes, for the current month’s billing cycle.

Return type:

MappedObject

types(*filters)[source]

Returns a paginated list of Object Storage Types.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-object-storage-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of Object Storage types that match the query.

Return type:

PaginatedList of ObjectStorageType

PlacementAPIGroup

Includes methods related to VM placement.

class linode_api4.linode_client.PlacementAPIGroup(client: BaseClient)[source]
group_create(label: str, region: Region | str, placement_group_type: PlacementGroupType, placement_group_policy: PlacementGroupPolicy, **kwargs) PlacementGroup[source]

NOTE: Placement Groups may not currently be available to all users.

Create a placement group with the specified parameters.

Parameters:
  • label (str) – The label for the placement group.

  • region (Union[Region, str]) – The region where the placement group will be created. Can be either a Region object or a string representing the region ID.

  • placement_group_type (PlacementGroupType) – The type of the placement group.

  • placement_group_policy (PlacementGroupPolicy) – The policy for assignments to this placement group.

Returns:

The new Placement Group.

Return type:

PlacementGroup

groups(*filters)[source]

NOTE: Placement Groups may not currently be available to all users.

Returns a list of Placement Groups on your account. You may filter this query to return only Placement Groups that match specific criteria:

groups = client.placement.groups(PlacementGroup.label == "test")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-placement-groups

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Placement Groups that matched the query.

Return type:

PaginatedList of PlacementGroup

PollingGroup

Includes methods related to account event polling.

class linode_api4.linode_client.PollingGroup(client: BaseClient)[source]

This group contains various helper functions for polling on Linode events.

event_poller_create(entity_type: str, action: str, entity_id: int | None = None) EventPoller[source]

Creates a new instance of the EventPoller class.

Parameters:
Returns:

The new EventPoller object.

Return type:

EventPoller

wait_for_entity_free(entity_type: str, entity_id: int, timeout: int = 240, interval: int = 5)[source]

Waits for all events relevant events to not be scheduled or in-progress.

Parameters:
  • entity_type (str) – The type of the entity to poll for events on. Valid values for this field can be found here: https://techdocs.akamai.com/linode-api/reference/get-events

  • entity_id (int) – The ID of the entity to poll for.

  • timeout (int) – The timeout in seconds for this polling operation.

  • interval (int) – The interval in seconds to wait between polls.

ProfileGroup

Includes methods for managing your user.

class linode_api4.linode_client.ProfileGroup(client: BaseClient)[source]

Collections related to your user.

__call__()[source]

Retrieve the acting user’s Profile, containing information about the current user such as their email address, username, and uid. This is intended to be called off of a LinodeClient object, like this:

profile = client.profile()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-profile

Returns:

The acting user’s profile.

Return type:

Profile

apps(*filters)[source]

Returns the Authorized Applications for this user

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-profile-apps

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Authorized Applications for this user

Return type:

PaginatedList of AuthorizedApp

logins()[source]

Returns the logins on your profile.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-profile-logins

Returns:

A list of logins for this profile.

Return type:

PaginatedList of ProfileLogin

phone_number_delete()[source]

Delete the verified phone number for the User making this request.

API Documentation: https://techdocs.akamai.com/linode-api/reference/delete-profile-phone-number

Returns:

Returns True if the operation was successful.

Return type:

bool

phone_number_verification_code_send(iso_code, phone_number)[source]

Send a one-time verification code via SMS message to the submitted phone number.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-profile-phone-number

Parameters:
  • iso_code (str) – The two-letter ISO 3166 country code associated with the phone number.

  • phone_number (str) – A valid phone number.

Returns:

Returns True if the operation was successful.

Return type:

bool

phone_number_verify(otp_code)[source]

Verify a phone number by confirming the one-time code received via SMS message after accessing the Phone Verification Code Send (POST /profile/phone-number) command.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-profile-phone-number-verify

Parameters:

otp_code (str) – The one-time code received via SMS message after accessing the Phone Verification Code Send

Returns:

Returns True if the operation was successful.

Return type:

bool

security_questions()[source]

Returns a collection of security questions and their responses, if any, for your User Profile.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-security-questions

security_questions_answer(questions)[source]

Adds security question responses for your User. Requires exactly three unique questions. Previous responses are overwritten if answered or reset to null if unanswered.

Example question: {

“question_id”: 11, “response”: “secret answer 3”

}

ssh_key_upload(key, label)[source]

Uploads a new SSH Public Key to your profile This key can be used in later Linode deployments.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-add-ssh-key

Parameters:
  • key (str) – The ssh key, or a path to the ssh key. If a path is provided, the file at the path must exist and be readable or an exception will be thrown.

  • label (str) – The name to give this key. This is purely aesthetic.

Returns:

The newly uploaded SSH Key

Return type:

SSHKey

Raises:

ValueError – If the key provided does not appear to be valid, and does not appear to be a path to a valid key.

ssh_keys(*filters)[source]

Returns the SSH Public Keys uploaded to your profile.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-ssh-keys

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of SSH Keys for this profile.

Return type:

PaginatedList of SSHKey

token_create(label=None, expiry=None, scopes=None, **kwargs)[source]

Creates and returns a new Personal Access Token.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-personal-access-token

Parameters:
  • label (str) – The label of the new Personal Access Token.

  • expiry (datetime or str) – When the new Personal Accses Token will expire.

  • scopes (str) – A space-separated list of OAuth scopes for this token.

Returns:

The new Personal Access Token.

Return type:

PersonalAccessToken

tokens(*filters)[source]

Returns the Person Access Tokens active for this user.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-personal-access-tokens

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of tokens that matches the query.

Return type:

PaginatedList of PersonalAccessToken

trusted_devices()[source]

Returns the Trusted Devices on your profile.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-devices

Returns:

A list of Trusted Devices for this profile.

Return type:

PaginatedList of TrustedDevice

user_preferences()[source]

View a list of user preferences tied to the OAuth client that generated the token making the request.

user_preferences_update(**preferences)[source]

Updates a user’s preferences.

RegionGroup

Includes methods for accessing information about Linode Regions.

class linode_api4.linode_client.RegionGroup(client: BaseClient)[source]
__call__(*filters)[source]

Returns the available Regions for Linode products.

This is intended to be called off of the LinodeClient class, like this:

region = client.regions()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-regions

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of available Regions.

Return type:

PaginatedList of Region

availability(*filters)[source]

Returns the availability of Linode plans within a Region.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-regions-availability

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of entries describing the availability of a plan in a region.

Return type:

PaginatedList of RegionAvailabilityEntry

vpc_availability(*filters)[source]

Returns VPC availability data for all regions.

NOTE: IPv6 VPCs may not currently be available to all users.

This endpoint supports pagination with the following parameters: - page: Page number (>= 1) - page_size: Number of items per page (25-500)

Pagination is handled automatically by PaginatedList. To configure page_size, set it when creating the LinodeClient:

client = LinodeClient(token, page_size=100)

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-regions-vpc-availability

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of VPC availability data for regions.

Return type:

PaginatedList of RegionVPCAvailability

SupportGroup

Includes methods for viewing and opening tickets with our support department.

class linode_api4.linode_client.SupportGroup(client: BaseClient)[source]

Collections related to support tickets.

ticket_open(summary, description, managed_issue=False, regarding=None, **kwargs)[source]

Opens a support ticket on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-ticket

Parameters:
  • summary (str) – The summary or title for this support ticket.

  • description (str) – The full details of the issue or question.

  • regarding – The resource being referred to in this ticket.

  • managed_issue (bool) – Designates if this ticket relates to a managed service.

Returns:

The new support ticket.

Return type:

SupportTicket

tickets(*filters)[source]

Returns a list of support tickets on this account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-tickets

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of support tickets on this account.

Return type:

PaginatedList of SupportTicket

TagGroup

Includes methods for managing Linode Tags.

class linode_api4.linode_client.TagGroup(client: BaseClient)[source]
__call__(*filters)[source]

Retrieves the Tags on your account. This may only be attempted by unrestricted users.

This is intended to be called off of the LinodeClient class, like this:

tags = client.tags()

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-domain

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Tags on the account.

Return type:

PaginatedList of Tag

create(label, instances=None, domains=None, nodebalancers=None, volumes=None, entities=None, reserved_ipv4_addresses=None)[source]

Creates a new Tag and optionally applies it to the given entities.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-tags

Parameters:
  • label (str) – The label for the new Tag

  • entities (list of Instance, Domain, NodeBalancer, and/or Volume) – A list of objects to apply this Tag to upon creation. May only be taggable types (Linode Instances, Domains, NodeBalancers, or Volumes). These are applied in addition to any IDs specified with instances, domains, nodebalancers, or volumes, and is a convenience for sending multiple entity types without sorting them yourself.

  • instances (list of Instance or list of int) – A list of Linode Instances to apply this Tag to upon creation

  • domains (list of Domain or list of int) – A list of Domains to apply this Tag to upon creation

  • nodebalancers (list of NodeBalancer or list of int) – A list of NodeBalancers to apply this Tag to upon creation

  • volumes (list of Volumes or list of int) – A list of Volumes to apply this Tag to upon creation

  • reserved_ipv4_addresses (list of str) – A list of reserved IPv4 addresses to apply this Tag to upon creation.

Returns:

The new Tag

Return type:

Tag

VolumeGroup

Includes methods for managing Linode Volumes.

class linode_api4.linode_client.VolumeGroup(client: BaseClient)[source]
__call__(*filters)[source]

Retrieves the Block Storage Volumes your user has access to.

This is intended to be called off of the LinodeClient class, like this:

volumes = client.volumes()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-volumes

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of Volumes the acting user can access.

Return type:

PaginatedList of Volume

create(label, region=None, linode=None, size=20, **kwargs)[source]

Creates a new Block Storage Volume, either in the given Region or attached to the given Instance.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-volumes

Parameters:
  • label (str) – The label for the new Volume.

  • region (Region or str) – The Region to create this Volume in. Not required if linode is provided.

  • linode (Instance or int) – The Instance to attach this Volume to. If not given, the new Volume will not be attached to anything.

  • size (int) – The size, in GB, of the new Volume. Defaults to 20.

  • tags (list[str]) – A list of tags to apply to the new volume. If any of the tags included do not exist, they will be created as part of this operation.

  • encryption (str) – Whether the new Volume should opt in or out of disk encryption.

Returns:

The new Volume.

Return type:

Volume

types(*filters)[source]

Returns a PaginatedList of VolumeType objects that represents a valid Volume type.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-volume-types

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A Paginated List of Volume types that match the query.

Return type:

PaginatedList of VolumeType

VPCGroup

Includes methods for managing Linode VPCs.

class linode_api4.linode_client.VPCGroup(client: BaseClient)[source]
__call__(*filters) PaginatedList[source]

Retrieves all of the VPCs the acting user has access to.

This is intended to be called off of the LinodeClient class, like this:

vpcs = client.vpcs()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-vpcs

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of VPC the acting user can access.

Return type:

PaginatedList of VPC

create(label: str, region: Region | str, description: str | None = None, subnets: List[Dict[str, Any]] | None = None, ipv6: List[VPCIPv6RangeOptions | Dict[str, Any]] | None = None, **kwargs) VPC[source]

Creates a new VPC under your Linode account.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-vpc

Parameters:
  • label (str) – The label of the newly created VPC.

  • region (Union[Region, str]) – The region of the newly created VPC.

  • description (Optional[str]) – The user-defined description of this VPC.

  • subnets (List[Dict[str, Any]]) – A list of subnets to create under this VPC.

  • ipv6 (List[Union[VPCIPv6RangeOptions, Dict[str, Any]]]) – The IPv6 address ranges for this VPC.

Returns:

The new VPC object.

Return type:

VPC

ips(*filters) PaginatedList[source]

Retrieves all of the VPC IP addresses for the current account matching the given filters.

This is intended to be called from the LinodeClient class, like this:

vpc_ips = client.vpcs.ips()

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-vpcs-ips

Parameters:

filters – Any number of filters to apply to this query. See Filtering Collections for more details on filtering.

Returns:

A list of VPCIPAddresses the acting user can access.

Return type:

PaginatedList of VPCIPAddress